#include #if USE_HIVE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace DB { template Range createRangeFromOrcStatistics(const StatisticsType * stats) { /// We must check if there are minumum or maximum values in statistics in case of /// null values or NaN/Inf values of double type. if (stats->hasMinimum() && stats->hasMaximum()) { return Range(FieldType(stats->getMinimum()), true, FieldType(stats->getMaximum()), true); } else if (stats->hasMinimum()) { return Range::createLeftBounded(FieldType(stats->getMinimum()), true); } else if (stats->hasMaximum()) { return Range::createRightBounded(FieldType(stats->getMaximum()), true); } else { return Range(); } } template Range createRangeFromParquetStatistics(std::shared_ptr stats) { /// We must check if there are minumum or maximum values in statistics in case of /// null values or NaN/Inf values of double type. if (!stats->HasMinMax()) return Range(); return Range(FieldType(stats->min()), true, FieldType(stats->max()), true); } Range createRangeFromParquetStatistics(std::shared_ptr stats) { if (!stats->HasMinMax()) return Range(); String min_val(reinterpret_cast(stats->min().ptr), stats->min().len); String max_val(reinterpret_cast(stats->max().ptr), stats->max().len); return Range(min_val, true, max_val, true); } Range HiveOrcFile::buildRange(const orc::ColumnStatistics * col_stats) { if (!col_stats || col_stats->hasNull()) return {}; if (const auto * int_stats = dynamic_cast(col_stats)) { return createRangeFromOrcStatistics(int_stats); } else if (const auto * double_stats = dynamic_cast(col_stats)) { return createRangeFromOrcStatistics(double_stats); } else if (const auto * string_stats = dynamic_cast(col_stats)) { return createRangeFromOrcStatistics(string_stats); } else if (const auto * bool_stats = dynamic_cast(col_stats)) { auto false_cnt = bool_stats->getFalseCount(); auto true_cnt = bool_stats->getTrueCount(); if (false_cnt && true_cnt) { return Range(UInt8(0), true, UInt8(1), true); } else if (false_cnt) { return Range::createLeftBounded(UInt8(0), true); } else if (true_cnt) { return Range::createRightBounded(UInt8(1), true); } } else if (const auto * timestamp_stats = dynamic_cast(col_stats)) { return createRangeFromOrcStatistics(timestamp_stats); } else if (const auto * date_stats = dynamic_cast(col_stats)) { return createRangeFromOrcStatistics(date_stats); } return {}; } void HiveOrcFile::prepareReader() { // TODO To be implemented } void HiveOrcFile::prepareColumnMapping() { // TODO To be implemented } bool HiveOrcFile::hasMinMaxIndex() const { return false; } std::unique_ptr HiveOrcFile::buildMinMaxIndex(const orc::Statistics * /*statistics*/) { // TODO To be implemented return {}; } void HiveOrcFile::loadMinMaxIndex() { // TODO To be implemented } bool HiveOrcFile::hasSubMinMaxIndex() const { return false; } void HiveOrcFile::loadSubMinMaxIndex() { // TODO To be implemented } bool HiveParquetFile::hasSubMinMaxIndex() const { // TODO To be implemented return false; } void HiveParquetFile::prepareReader() { // TODO To be implemented } void HiveParquetFile::loadSubMinMaxIndex() { // TODO To be implemented } } #endif