Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5550

SELECT non-existent column produces empty required VARCHAR

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.10.0
    • Fix Version/s: Future
    • Component/s: Storage - Text & CSV
    • Labels:
      None

      Description

      Drill's CSV column reader supports two forms of files:

      • Files with column headers as the first line of the file.
      • Files without column headers.

      The CSV storage plugin specifies which format to use for files accessed via that storage plugin config.

      Suppose we have a CSV file with headers:

      a,b,c
      10,foo,bar
      

      Suppose we configure a storage plugin to use headers:

          TextFormatConfig csvFormat = new TextFormatConfig();
          csvFormat.fieldDelimiter = ',';
          csvFormat.skipFirstLine = false;
          csvFormat.extractHeader = true;
      

      (The above can also be done using JSON when running Drill as a server.)

      Execute the following query:

      SELECT a, c, d FROM `dfs.data.example.csv`
      

      Results:

      a,c,d
      10,bar,
      

      The actual type of column d is non-nullable VARCHAR.

      This is inconsistent with other parts of Drill in two ways, one may be a bug. Most other parts of Drill use a nullable INT for "missing" columns.

      1. For CSV it makes sense for the data type to be VARCHAR, since all CSV columns are of that type.
      2. It may not make sense for the column to be non-nullable and blank rather than nullable and NULL. In SQL, NULL means that the data is unknown, which is the case here.

      In the future, we may want to use some other indication for a missing column. Until then, the requested change is to make the type of a missing CSV column a nullable VARCHAR set to value NULL.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              paul-rogers Paul Rogers
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: