中获得多少个字符
这不需要解释。但是有人可以描述子字符引起的POS参数背后的逻辑,因为我无法理解这一点(使用Spark 2.1):
scala> val df = Seq("abcdef").toDS()
df: org.apache.spark.sql.Dataset[String] = [value: string]
scala> df.show
+------+
| value|
+------+
|abcdef|
+------+
scala> df.selectExpr("substring(value, 0, 2)", "substring(value, 1, 2)", "substring(value, 2,2)", "substring(value, 3,2)").show
+----------------------+----------------------+----------------------+----------------------+
|substring(value, 0, 2)|substring(value, 1, 2)|substring(value, 2, 2)|substring(value, 3, 2)|
+----------------------+----------------------+----------------------+----------------------+
| ab| ab| bc| cd|
+----------------------+----------------------+----------------------+----------------------+
第一个值是从应启动的索引(从1起从0开始)第二个值是从索引