dolphindb - 使用 dolphindb 中的 unionAll 函数连接两个表
问题描述
我创建了两个可以通过 id 列链接的表。table1 中的 x 列是 int。table2 中的 x 列是字符串。我尝试通过调用 unionAll 函数来加入这两个表,但都返回错误:
t1=table(1 2 3 as id, 11 12 13 as x)
t2=table(3 4 5 as id, `a`b`c as x)
unionAll(t1,t2);
/*Error:
unionAll(t1, t2) => Failed to append data to column 'x'
*/
t1=table(1 2 3 as id, 11 12 13 as x)
t2=table(3 4 5 as id, `a`b`c as x)
unionAll(t1,t2,true);
/*Error:
unionAll(t1, t2, 1) => The data type of column [x] of the input table [#1] is inconsistent
with that of other input tables.
*/
解决方案
因为 t1 和 t2 的 x 列中的数据类型不同,所以不能合并到同一列中。可以将t2的x列的列名修改为y,然后使用unionAll连接:
t1=table(1 2 3 as id, 11 12 13 as x)
t2=table(3 4 5 as id, `a `b `c as y)
unionAll(t1,t2, true)
ID | X | 是的 |
---|---|---|
1 | 11 | |
2 | 12 | |
3 | 13 | |
3 | 一个 | |
4 | b | |
5 | C |
推荐阅读
- python - 背包 I/O 经典问题获取最不值钱的物品
- javascript - 删除按钮单击时重新排列附加的文本输入
- ios - 如何在 iOS 的 HERE 地图中点击标记实现可点击的信息气泡?
- multithreading - 从分离的线程安全地访问局部静态变量
- serilog - Polly - 如何记录最终错误并继续?
- javascript - Integrate Salesforce registration page with VanillaJS oidc-client-js, getting the error - No matching state found in storage
- django - 创建了一个基于 django 的应用程序,并希望使用图形 API 读取用户的邮件(但没有用户在场)
- java - 在不同时间发送多条消息 Android Java
- php - 有没有办法使用 GET 方法中的变量在 laravel 中使用 where like 查询?
- javascript - 加载更多按钮