You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Yuming Wang (JIRA)" <ji...@apache.org> on 2019/07/18 06:26:00 UTC
[jira] [Updated] (SPARK-28435) Support cast StringType to
IntervalType for SQL interface
[ https://issues.apache.org/jira/browse/SPARK-28435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yuming Wang updated SPARK-28435:
--------------------------------
Summary: Support cast StringType to IntervalType for SQL interface (was: Support cast string to interval for SQL interface)
> Support cast StringType to IntervalType for SQL interface
> ---------------------------------------------------------
>
> Key: SPARK-28435
> URL: https://issues.apache.org/jira/browse/SPARK-28435
> Project: Spark
> Issue Type: Sub-task
> Components: SQL
> Affects Versions: 3.0.0
> Reporter: Yuming Wang
> Priority: Major
>
> Scala interface support cast string to interval:
> {code:scala}
> import org.apache.spark.sql.types._
> import org.apache.spark.sql.catalyst.expressions._
> Cast(Literal("interval 3 month 1 hours"), CalendarIntervalType).eval()
> res0: Any = interval 3 months 1 hours
> {code}
> But SQL interface does not support it:
> {code:sql}
> scala> spark.sql("SELECT CAST('interval 3 month 1 hour' AS interval)").show
> org.apache.spark.sql.catalyst.parser.ParseException:
> DataType interval is not supported.(line 1, pos 41)
> == SQL ==
> SELECT CAST('interval 3 month 1 hour' AS interval)
> -----------------------------------------^^^
> at org.apache.spark.sql.catalyst.parser.AstBuilder.$anonfun$visitPrimitiveDataType$1(AstBuilder.scala:1931)
> at org.apache.spark.sql.catalyst.parser.ParserUtils$.withOrigin(ParserUtils.scala:108)
> at org.apache.spark.sql.catalyst.parser.AstBuilder.visitPrimitiveDataType(AstBuilder.scala:1909)
> at org.apache.spark.sql.catalyst.parser.AstBuilder.visitPrimitiveDataType(AstBuilder.scala:52)
> at org.apache.spark.sql.catalyst.parser.SqlBaseParser$PrimitiveDataTypeContext.accept(SqlBaseParser.java:15397)
> at org.apache.spark.sql.catalyst.parser.AstBuilder.typedVisit(AstBuilder.scala:58)
> at org.apache.spark.sql.catalyst.parser.AstBuilder.visitSparkDataType(AstBuilder.scala:1903)
> at org.apache.spark.sql.catalyst.parser.AstBuilder.$anonfun$visitCast$1(AstBuilder.scala:1334)
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org