【问题标题】:Hive External Table Schema ReconnectionHive 外部表架构重新连接
【发布时间】:2019-02-12 07:42:08
【问题描述】:

假设我通过删除表删除了现有 hive 外部表的架构,数据仍然存在于位置。

然后,我在现有数据的相同位置重新创建了具有相同架构的外部表。

  1. 查询时会得到结果吗?
  2. 如果不是如何获取查询结果?
  3. 我们可以在 hive 中连接到 derby DB 吗?

【问题讨论】:

    标签: hadoop hive hdfs data-warehouse


    【解决方案1】:

    您应该尝试过,因为您已经知道即使删除表后该文件仍然存在。

    我有一张桌子 - time_file;

    hive> show create table time_file;
    OK
    CREATE EXTERNAL TABLE `time_file`(
      `tm_dim_key` string,
      ......
      ....)
    ROW FORMAT SERDE
      'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
    WITH SERDEPROPERTIES (
      'field.delim'='|',
      'serialization.format'='|')
    STORED AS INPUTFORMAT
      'org.apache.hadoop.mapred.TextInputFormat'
    OUTPUTFORMAT
      'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
    LOCATION
      'maprfs:/user/vijay/scm';
    

    删除表 -

    hive> drop table if exists time_file;
    OK
    Time taken: 0.1 seconds
    

    删除后的表文件仍然存在于hadoop位置-

    hive> !hadoop fs -ls /user/supplychainadmin/alb_supply_chain_ext
        > ;
    Found 1 items
    -rwxr-xr-x   3 scm scm   74163231 2019-02-07 04:21 /user/vijay/scm/time_file1.dat
    

    再次创建表后-

    我们可以查询数据

    hive> select * from time_file limit 1;
    OK
    735918                                          735918  ABS Fiscal Year  2016           11280   50343524        50343524                                    Year     02-25-17        25                                                      1       ABS Fiscal Year  2016                           1       Saturday    7
    Time taken: 0.106 seconds, Fetched: 1 row(s)
    hive>
    

    【讨论】:

      【解决方案2】:

      假设您通过删除表删除了现有 hive 外部表的架构,数据仍然存在于位置。

      然后,如果您在现有数据的相同位置重新创建具有相同架构的外部表。

      答:1)你会得到你得到的结果。 删除外部配置单元表只会从配置的 RDBMS 大型存储中删除元数据。

      ANS:3) 是的,您可以在嵌入式模式下获得默认的 derby DB,或者如果您明确需要 derby DB 在分布式模式下,可以在hive.site.xml文件中配置

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-29
        • 2021-10-21
        • 1970-01-01
        • 2019-01-13
        相关资源
        最近更新 更多