You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Bill Oliver (JIRA)" <ji...@apache.org> on 2014/04/24 16:48:15 UTC

[jira] [Created] (HIVE-6969) SQL literal should be a fixed length, not string

Bill Oliver created HIVE-6969:
---------------------------------

             Summary: SQL literal should be a fixed length, not string
                 Key: HIVE-6969
                 URL: https://issues.apache.org/jira/browse/HIVE-6969
             Project: Hive
          Issue Type: Bug
    Affects Versions: 0.12.0
         Environment: I tried this with Hive .12 using cdh5.0. 
            Reporter: Bill Oliver


I checked to see if this was already reported, but could not find it.

Consider this simple query with a SQL literal:

hive> explain select 'abc' from pplsqlb0;
OK
ABSTRACT SYNTAX TREE:
  (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME pplsqlb0))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR 'abc'))))

STAGE DEPENDENCIES:
  Stage-1 is a root stage
  Stage-0 is a root stage

STAGE PLANS:
  Stage: Stage-1
    Map Reduce
      Alias -> Map Operator Tree:
        pplsqlb0
          TableScan
            alias: pplsqlb0
            Select Operator
              expressions:
                    expr: 'abc'
                    type: string
              outputColumnNames: _col0
              File Output Operator
                compressed: false
                GlobalTableId: 0
                table:
                    input format: org.apache.hadoop.mapred.TextInputFormat
                    output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
                    serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe

  Stage: Stage-0
    Fetch Operator
      limit: -1


'abc' is treated as a STRING type. It would be better if it were handled as a CHAR(3) type. If the length > 255, I would like to see it as a VARCHAR(n) type.

Also, string functions based on the literal, such as TRIM('abc') should reflect the correct length. SUBSTRING('abc', 1, 1) should return CHAR(1).

Thanks for any help on this!

-bill



--
This message was sent by Atlassian JIRA
(v6.2#6252)