曾使用Flink API创建Hive表,然后查询时碰到过这个问题:
hive>select * from test_db.test_flink_hive_table;
FAILED: SemanticException Line 0:-1 Invalid column reference 'TOK_ALLCOLREF'
但是如果使用Flink SQL去查询却是正常的。切换其他引擎,比如使用Trino按照相同的方式创建表,也是正常查询,那问题自然就是Flink的处理方式不同了。
用Hive SQL打印表的详情来研究下:
hive>desc formatted test_db.test_flink_hive_table;
OK
# col_name data_type comment
# Detailed Table Information
Database: test_db
OwnerType: USER
Owner: null
LastAccessTime: UNKNOWN
Retention: 0
Location: file:/tmp/test_db/test_flink_hive_table
Table Type: MANAGED_TABLE
Table Parameters:
flink.comment test crreate flink hive table
flink.schema.0.data-type INT
flink.schema.0.name id
flink.schema.1.data-type VARCHAR(2147483647)
flink.schema.1.name data
is_generic true
transient_lastDdlTime 1678861999
# Storage Information
SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
InputFormat: org.apache.hadoop.mapred.TextInputFormat
OutputFormat: org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat
Compressed: No
Num Buckets: 0
Bucket Col

文章讨论了使用FlinkAPI创建Hive表后,在Hive中查询时遇到的SemanticException,对比了FlinkSQL创建表的正常情况。问题在于FlinkAPI创建的表缺少connector参数,导致字段信息存储在表参数中而非常规字段列表。解决方案包括设置connector为hive或使用Flink的HiveSQL方言。
最低0.47元/天 解锁文章
1503

被折叠的 条评论
为什么被折叠?



