简体   繁体   English

如何将字符串列表转换/拆分为要在 sql 中使用的列 spark java

[英]how to convert/split a list of strings into columns to be used in sql in spark java

i have a List=["a","b","c"] and i need to split this list into strings to use them like:我有一个 List=["a","b","c"] 并且我需要将这个列表拆分成字符串以便像这样使用它们:

SELECT columns SELECT 列

i tried我试过

String.join(",",["a","b","c"])

but i obtain usually the same error (because i think that it's seen like an only column):但我通常会遇到同样的错误(因为我认为它被视为唯一的专栏):

org.apache.spark.sql.AnalysisException: cannot resolve '`a,b,c`'

plz how can split the list to multiple strings to use them in my select请问如何将列表拆分为多个字符串以在我的 select 中使用它们

your written code has problem where you passed an array of values which you have to write it as below:您编写的代码有问题,您传递的值数组必须按如下方式编写:

String value = String.join(",", new String[] {"a","b","c"});
System.out.println(value);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM