【问题标题】:in Beeline,use "create table table_name as select * from" doesn't work在直线中,使用“create table table_name as select * from”不起作用
【发布时间】:2020-08-02 04:19:23
【问题描述】:

在Beeline中,我使用“create table new_table_name as select * from exists_name”创建新表,表创建成功,但是没有数据。当我使用相同的“select * from exists_name”创建临时表时,临时表有数据。 直线版本是Beeline version 3.1.0.3.1.5.0-152 by Apache Hive

【问题讨论】:

  • 您的确切创建 SQL 是什么?因为直线/命令工具有时不会创建正确的模式。你用过像create table target_db.new_table_name as select * from source_db.exists_name
  • 是的,我尝试使用create table target_db.new_table_name as select * from source_db.exists_name。它也没有用
  • 你有没有收到这样的工作总结消息 - INFO : Execution completed successfully INFO : Moving data to: hdfs://loc/tmp from hdfs://db-ns/ sw/schema/.hive-staging_hive_2020-08-03_00-58-40_904_7739683806805718609-35074 INFO : Starting task [Stage-2:STATS] in serial mode INFO : Table schema.tmp stats: [numFiles=2, numRows=2414, total Size=450056, rawDataSize=447642] INFO : Completed executing command(queryId=hive_20200803005858_123d8faf-df00-4e4b-9ba5-2b91858a7b54); Time taken: 102.659 seconds INFO : OK No rows affected (103.867 seconds)

标签: hive hiveql beeline


【解决方案1】:

我查了关于Create Table As Select (CTAS)的HIVE官方文档, CTAS 有以下限制:

  1. 目标表不能是外部表。
  2. 目标表不能是列表分桶表。

在Beeline中,当我使用create table new_table_name as select * from exists_name创建一个新表时,它总是创建一个外部表,可能是这个原因

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-29
    • 2013-12-07
    • 2010-11-27
    • 1970-01-01
    • 1970-01-01
    • 2020-11-27
    相关资源
    最近更新 更多