- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是运行了几个月的遗留 R 代码。我能够从 R 中读取/删除 Teradata 中的表,但无法将数据从数据框写入表中。
我尝试过删除表并重新创建和编写不同的数据框。
sqlSave(ch, df, tablename = paste("scenario.table_storetype"),rownames=F)
我遇到了以下错误
Error in sqlColumns(channel, tablename)[4L][, 1L]: incorrect number of dimensions Traceback:
1. sqlSave(ch, df, tablename = paste("scenario.table_storetype"), . rownames = F, safer = FALSE, append = T)
2. sqlwrite(channel, tablename, dat, verbose = verbose, fast = fast, . test = test, nastring = nastring)
dput(head(df))
输出:结构(列表(预测= c(36659805.75,28117111.75,27005618.75,33650734.4166667, 27243750.75, 26907919.0833333), 实际 = c(38293943,29892143, 27016674, 33524728, 27252399, 26521098), BC = c("Prepared Salad, Fruit & Veg",“预制沙拉、水果和蔬菜”、“预制沙拉、水果和蔬菜”、“预制沙拉、水果和蔬菜”、“预制沙拉、水果和蔬菜”、“准备好的沙拉、水果和蔬菜”), period = 201904:201909, how = c("a_tslm_mape","a_tslm_mape", "a_tslm_mape", "a_tslm_mape", "a_tslm_mape", "a_tslm_mape")), .Names = c("预测", "实际", "BC", "期间", "如何"), row.names = c(NA,6L), class = "data.frame")
dput(head(df))
四舍五入后 - 输出:结构(列表(预测= c(36659805.75,28117111.75,27005618.75,33650734.42, 27243750.75, 26907919.08), 实际 = c(38293943,29892143, 27016674, 33524728, 27252399, 26521098), BC = c("Prepared Salad, Fruit & Veg",“预制沙拉、水果和蔬菜”、“预制沙拉、水果和蔬菜”、“预制沙拉、水果和蔬菜”、“预制沙拉、水果和蔬菜”、“准备好的沙拉、水果和蔬菜”), period = 201904:201909, how = c("a_tslm_mape","a_tslm_mape", "a_tslm_mape", "a_tslm_mape", "a_tslm_mape", "a_tslm_mape")), .Names = c("预测", "实际", "BC", "期间", "如何"), row.names = c(NA,6L), class = "data.frame")
最佳答案
显然,您的数字非常大,但精度各不相同。动态创建表时,数字字段可能映射为 DECIMAL(n, m)
2 的比例可以由第一个值 36659805.75
设置的类型,但这后来与 33650734.4166667
的比例为 7 发生冲突。
考虑使用 sqlSave
的 varTypes 参数显式定义数据类型。根据文档:
varTypes: an optional named character vector giving the DBMSs datatypes to be used for some (or all) of the columns if a table is to be created
此外,在 R 中进行相应舍入以符合 Teradata 列类型的精度需求
df$forecast <- round(df$forecast, 4) # PRECISION OF 4
max(nchar(df$BC)) # FIND MAX CHARS
max(nchar(df$how)) # FIND MAX CHARS
tbl_types = c(forecast = "DECIMAL(12, 4)",
actual = "DECIMAL(12, 4)",
BC = "VARCHAR(50)",
period = "INTEGER",
how = "VARCHAR(20)")
sqlSave(ch, df, tablename = paste("scenario.table_storetype"),
varTypes = tbl_types, rownames = FALSE)
关于r - 使用 RODBC sqlSave 将数据框从 R 写入 Teradata 中的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56584748/
Teradata 中是否有一个函数,可以通过将任意年份的日、月作为参数来“生成”日期?那么如果我有整数参数 p1_day、p2_month 和 p3_year (顺便说一句,它们是属性),是否有一个像
我试图搜索,但我没有找到任何东西。我正在尝试将两列添加到具有默认值 (Teradata) 的表中。我正在尝试这个声明 ALTER TABLE TEST add (DWH_Change_dt date
Teradata 中是否有一个函数可以通过给定任何年份的日、月作为参数来“制作”一个日期?所以,如果我有整数参数 p1_day、p2_month 和 p3_year(顺便说一下,它们是属性),是否有类
在我的 Teradata 表中,dhTimestamp 列下有纪元时间戳 dhTimestamp 1435308067705 1434965874565 1434763800794 14347
谁能解释 Teradata 中的查询带? 我已经对此进行了很多搜索,但无法获得我能理解的信息。 请详细一点。 谢谢!!! 最佳答案 TeraDATA 中的查询分段: Query Banding 提供了
Teradata 数据库中有特殊字符,我想删除它。 Example - special character: "aa€bb" (special charcter is "€" sign) Desir
GitHub 事件只是 empty last month , 至少 latest release 0.10.1 的下载链接(2019 年 3 月)无路可走 对于 VirtualBox images 同
我正在寻找一种方法来识别授予特定数据库中用户的默认权限。我已经尝试过: select * from dbc.allrights where username='user-id' and datab
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 5 年前。 Improve this ques
如何计算前 7 天的数据(前一周的周日至周六)。无论一周中的哪一天运行,它都应始终给出前一周的星期日至星期六。谢谢 最佳答案 您的 Teradata 版本是什么? TD14 支持 NEXT_DAY,它
我为参加马拉松比赛的人准备了下表 person start end mike 2-Jun-14 2-Jul-14 nike 3-Jul-14 9-Aug-14 m
我想报告特定 Teradata 数据库的各种统计数据,尤其是“可用空间”。表倾斜是否应该包括在计算中?例如,有人建议了以下查询: SELECT databasename , SUM(maxp
我正在编写一个查询以从数据转储中获取 SCD 2 类型的数据。 我的数据和代码如下: create table promotions ( start_date date, end_date date,
我在 Teradata 中有一张表。我想知道它的大小。对于 Teradata 中的数据库,同样的事情可能会很有趣。 我该怎么做? 最佳答案 要检查您的 table 大小,您可以从 dbc.tables
我正在寻找类似于 ISNUMERIC() 的函数来自 T-SQL 和 Teradata SQL。如果字符类型字段中包含的数据都是数字,我想要一个简单的方法来返回一个 bool 值(或数字 1/0)。
我有下表 CREATE SET TABLE myTab,FALLBACK,NO BEFORE JOURNAL,NO AFTER JOURNAL,CHECKSUM = DEFAULT,DEFAULT M
是否可以将 Teradata 表中的日期直接传输到 .csv 文件中。问题是 - 我的表有超过 1800 万行。如果是,请发送告诉我过程 最佳答案 对于这样大小的表,我建议使用 FastExport
请帮助指导如何在 Teradata 中删除数据库。 当我运行命令DROP DATABASE database_name时,我收到错误消息: *** Failure 3552 Cannot DROP d
teradata中是否有相当于oracle的Listagg函数的函数。递归是我尝试过的一个选项,但想要其他的东西。 谢谢阿里特拉 最佳答案 如果安装了 Teradata 的 XML 服务(从 14.1
我在Teradata 14 中有下表,不允许我自己编写过程和函数,但我可以使用strtok、strtok_split_to_table 等等 id property 1 1234X (Yel),
我是一名优秀的程序员,十分优秀!