【问题标题】:Querying nested fields in Flink SQL 1.11Flink SQL 1.11 中查询嵌套字段
【发布时间】:2021-09-23 16:20:42
【问题描述】:

我有一个如下所示的架构: 表:org_table

`transaction_amt` VARCHAR(64) NOT NULL,
`transaction_adj_amt` BIGINT NOT NULL ,
`event_time` TIMESTAMP(3),
`fd_output` ROW<`restime`  BIGINT `outcome` VARCHAR(64)>,

当我这样查询这个表时:

SELECT transaction_amt, transaction_adj_amt, event_time, fd_output.restime as response_time, fd_output.outcome as outcome,  YEAR(event_time), MONTH(event_time) 
           FROM org_table

在表上运行上述查询时出现错误。我在这里有什么遗漏吗?

scala.MatchError: CAST (of class org.apache.calcite.sql.fun.SqlCastFunction

【问题讨论】:

    标签: apache-flink flink-sql pyflink


    【解决方案1】:

    可能需要注意 Flink 内置函数的输入参数,比如 YEAR 和 MONTH 函数,它们的输入参数是日期类型

    Flink 内置功能说明可以参考 https://ci.apache.org/projects/flink/flink-docs-release-1.13/docs/dev/table/functions/systemfunctions/

    【讨论】:

    • 如果我从查询中删除行字段,它甚至适用于 YEAR 和 MONTH(内置函数)
    【解决方案2】:

    尝试fd_output.get(0) 访问休息时间,fd_output.get(1) 访问结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-17
      • 2019-05-05
      • 1970-01-01
      相关资源
      最近更新 更多