我们能否将String列设置为partitionColumn?(Can we able to set String column as partitionColumn?)
表只有String列作为主列
EMPLOYEE_ID
如何对其进行分区。
val destination = spark.read.options(options).jdbc(options("url"), options("dbtable"), "EMPLOYEE_ID", P00100001, P00100005000000, 10, new java.util.Properties()).rdd.map(_.mkString(","))
有没有其他方法来读取JDBC表并进行处理。
Table only has String column as primary column
EMPLOYEE_ID
how to partition it.
val destination = spark.read.options(options).jdbc(options("url"), options("dbtable"), "EMPLOYEE_ID", P00100001, P00100005000000, 10, new java.util.Properties()).rdd.map(_.mkString(","))
Is there any other way to Read JDBC table and process it.
原文:https://stackoverflow.com/questions/46684689
最满意答案
这不可能。 这里只能使用整数列。 如果您的数据库支持rowid的某个变体,它是整数或可以转换为整数,您可以在查询中提取它(伪代码):
(SELECT CAST(rowid AS INTEGER), * FROM TABLE) AS tmp
It is not possible. Only integer columns can be used here. If your database supports some variant of rowid, which is integer or can be casted to integer, you can extract it in a query (pseudocode):
(SELECT CAST(rowid AS INTEGER), * FROM TABLE) AS tmp
相关问答
更多-
您可以在创建表格时指定列的默认值。 (它看起来好像你可以使用ALTER语句添加一个默认值,所以你必须重新创建你的表。) CREATE TABLE your_table_name (MainContactName TEXT NOT NULL DEFAULT '') 没有为MainContactName指定值插入的新行将具有MainContactName字段的空字符串。 您可以尝试将空值插入到该字段中,但由于NOT NULL约束,查询会爆炸。 You can specify a default value f ...
-
在单独的列中找到字符串时,将数据框中的列设置为值(Set column in data frame to value when string is found in separate column)[2021-11-16]
注意replace和map之间的区别: map将不返回NaN匹配项。 稍后的ffill将从前一行的数据填充NaN 。 df.assign(c=df.a.map({'z':'123','y':'321'}).ffill()) a b c 0 z 4 123 1 s 5 123 2 u 4 123 3 y 3 321 Notice the difference between replace and map: map will return no match item ... -
我们可以在两者之间使用sort来sort每个'ID'中的'Product'进行sort df %>% group_by(ID) %>% summarise(Product = toString(unique(sort(Product)))) # ID Product # (fctr) (chr) #1 1 A, B #2 2 A, B #3 3 C #4 4 A, B, C 使用data.table语法的替代方法是 ...
-
您不能为字符串设置最小长度约束(至少在MySQL中)。 在这里,您可以使用类似的方法在验证期间通过约束实现最小长度约束。 $this->validate($request , [ 'name' =>'required|min:1' , 'email' =>'required' , 'phone_number' =>'required' , ]); 如果您坚持甚至无法使用空字符串保存模型,则可以通过模型事 ...
-
您是否尝试覆盖Product类的ToString()方法? 该问题可以在新的全新控制台应用程序中重现。 static void Main(string[] args) { Product product = new Product { Id = 1, Number = 1, Description = "TheFirstProduct", }; OrderDetail detail = new OrderDetail ...
-
似乎没错,除了你没有初始化你的列表: names = new ArrayList
(); It seems right, except that you didn't initialize your list: names = new ArrayList (); -
这不可能。 这里只能使用整数列。 如果您的数据库支持rowid的某个变体,它是整数或可以转换为整数,您可以在查询中提取它(伪代码): (SELECT CAST(rowid AS INTEGER), * FROM TABLE) AS tmp It is not possible. Only integer columns can be used here. If your database supports some variant of rowid, which is integer or can be ...
-
以下将Matt(Lima)建议的公式集成到实际的UPDATE查询中; 它还处理各种情况,如 当只有一个名字时, 当有前导或尾随空格时 当有多个空格将名字与姓氏隔开时 或者,可以通过添加WHERE子句(WHERE CustomerName like('%%'))来取消旨在确保有空间的额外测试。 -- Ensure no leading nor trailing spaces UPDATE myTable SET CustomerName = TRIM(CustomerName) UPDATE myTable ...
-
触发器示例 CREATE TRIGGER upd_check BEFORE UPDATE ON account FOR EACH ROW BEGIN IF NEW.amount is NULL THEN SET NEW.item = 0; END IF; END; TRIGGERS EXAMPLES CREATE TRIGGER upd_check BEFORE UPDATE ON account FOR EACH ROW BEGIN IF ...
-
对于表中的每一行grep第一个值为"user_id"值,并将结果放入列user_id 。 df$user_id <- apply(df, 1, function(x) grep("user_id", x, value = TRUE)[1]) For every row in your table grep first value that has "user_id" in it and put result into column user_id. df$user_id <- apply(df, 1, f ...