Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-19247

StatsOptimizer: Missing stats fast-path for Date

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2.1, 2.2.0, 2.3.2, 3.0.0
    • 3.1.0, 3.0.0
    • Statistics
    • None

    Description

      2018-04-19T18:57:24,268 DEBUG [67259108-c184-4c92-9e18-9e2969244442 HiveServer2-Handler-Pool: Thread-73]: optimizer.StatsOptimizer (StatsOptimizer.java:process(614)) - Unsupported type: date encountered in metadata optimizer for column : jour
      
      if (udaf instanceof GenericUDAFMin) {
                  ExprNodeColumnDesc colDesc = (ExprNodeColumnDesc)exprMap.get(((ExprNodeColumnDesc)aggr.getParameters().get(0)).getColumn());
                  String colName = colDesc.getColumn();
                  StatType type = getType(colDesc.getTypeString());
                  if (!tbl.isPartitioned()) {
                    if (!StatsSetupConst.areColumnStatsUptoDate(tbl.getParameters(), colName)) {
                      Logger.debug("Stats for table : " + tbl.getTableName() + " column " + colName
                          + " are not up to date.");
                      return null;
                    }
                    ColumnStatisticsData statData = hive.getMSC().getTableColumnStatistics(
                        tbl.getDbName(), tbl.getTableName(), Lists.newArrayList(colName))
                        .get(0).getStatsData();
                    String name = colDesc.getTypeString().toUpperCase();
                    switch (type) {
                      case Integeral: {
                        LongSubType subType = LongSubType.valueOf(name);
                        LongColumnStatsData lstats = statData.getLongStats();
                        if (lstats.isSetLowValue()) {
                          oneRow.add(subType.cast(lstats.getLowValue()));
                        } else {
                          oneRow.add(null);
                        }
                        break;
                      }
                      case Double: {
                        DoubleSubType subType = DoubleSubType.valueOf(name);
                        DoubleColumnStatsData dstats = statData.getDoubleStats();
                        if (dstats.isSetLowValue()) {
                          oneRow.add(subType.cast(dstats.getLowValue()));
                        } else {
                          oneRow.add(null);
                        }
                        break;
                      }
                      default: // unsupported type
                        Logger.debug("Unsupported type: " + colDesc.getTypeString() + " encountered in " +
                            "metadata optimizer for column : " + colName);
                        return null;
                    }
                  }
      
          enum StatType{
            Integeral,
            Double,
            String,
            Boolean,
            Binary,
            Unsupported
          }
      
          enum LongSubType {
            BIGINT { @Override
            Object cast(long longValue) { return longValue; } },
            INT { @Override
            Object cast(long longValue) { return (int)longValue; } },
            SMALLINT { @Override
            Object cast(long longValue) { return (short)longValue; } },
            TINYINT { @Override
            Object cast(long longValue) { return (byte)longValue; } };
      
            abstract Object cast(long longValue);
          }
      

      Date is stored in stats (& also the typo there).

      Attachments

        1. HIVE-19247.1.patch
          14 kB
          Gopal Vijayaraghavan

        Issue Links

          Activity

            People

              gopalv Gopal Vijayaraghavan
              gopalv Gopal Vijayaraghavan
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: