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

Infer constant types from columns before strict type validation

    XMLWordPrintableJSON

Details

    Description

      HIVE-2249 introduced some specialized type inference logic that kicks in when there are comparisons between columns and numeric constant expressions.

      Consider for instance a comparison between a BIGINT column and a STRING constant.

      SELECT * FROM table WHERE c_bigint = '9223372036854775807'
      

      The type derivation logic will attempt to convert the STRING constant to BIGINT and evaluate the expression by comparing long values.

      Currently (commit 5cbffb532a586226500abc498d6505722d62234d), the query above throws the following ERROR/WARNING:

      Comparing bigint and string may result in loss of information.
      

      This is due to strict type checking (controlled via hive.strict.checks.type.safety property) that is now applied before the constant type inference logic described above.

      In this case, the ERROR/WARNING is a bit misleading since there is no real risk for losing precision/information since the STRING constant fits into a BIGINT (Java long) and the whole comparison can be evaluated without precision loss.

      For quite some time, strict type checking was performed after constant type inference (and not before) but the behavior was changed unintentionally by HIVE-23100.

      The goal of this change is to perform constant type inference before strict type validation (behavior before HIVE-23100) to restore backward compatibility and remove some unnecessary warnings/errors during compilation.

      Attachments

        Issue Links

          Activity

            People

              zabetak Stamatis Zampetakis
              zabetak Stamatis Zampetakis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: