代码之家  ›  专栏  ›  技术社区  ›  Stanleyrr

从另一个表插入数据后,按列划分的配置单元将变为全部0

  •  0
  • Stanleyrr  · 技术社区  · 7 年前

    我使用Hortonworks在配置单元中创建分区表,并使用配置单元中的另一个表将数据插入其中。问题是,在我将数据插入到我创建的表中之后,结果表中分区列(passenger\u count)中的所有值都显示为0,即使原始表中没有一个值是0。

    1. 运行以下查询以创建名为“date\u partitioned”的表:

      create table date_partitioned
      (tpep_dropoff_datetime string, trip_distance double)
      partitioned by (passenger_count int);
      
    2. INSERT INTO TABLE date_partitioned
      PARTITION (passenger_count)
      SELECT tpep_dropoff_datetime, trip_distance, passenger_count
      FROM trips_raw;
      

    “trips\u raw”的列类型和示例值显示在下面的屏幕截图中: enter image description here enter image description here

    如您所见,“passenger\u count”列是int类型,包含非零值。但是当我查看'date\u partitioned'表的结果时,'passenger\u count'列的值都显示为0。该表还创建了一个重复的“passenger\u count”(因此它有2个“passenger\u count”列,其中一个是空的)。从下面的截图可以看到:

    enter image description here enter image description here

    如有任何建议,将不胜感激。我很好奇,为什么“passenger\u count”在原始列没有0的情况下在结果表中显示为0,为什么在结果表中有一个额外的“passenger\u count”列。

    1 回复  |  直到 7 年前
        1
  •  2
  •   justcode    7 年前

    您确定为乘客计数加载的所有行都是0吗?你能在两张桌子上进行计数和分组吗?也许你只是在采样所有的零?