Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-28767

ParseException: no viable alternative at input 'year'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.0.0
    • None
    • SQL
    • None

    Description

      The following query in timestamp.sql:

      -- !query 13
      SELECT '' AS `54`, d1 as `timestamp`,
          date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
          date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
          date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
          FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'
      -- !query 13 schema
      struct<>
      -- !query 13 output
      

      causes the error:

      org.apache.spark.sql.catalyst.parser.ParseException
      
      no viable alternative at input 'year'(line 2, pos 30)
      
      == SQL ==
      SELECT '' AS `54`, d1 as `timestamp`,
          date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
      ------------------------------^^^
          date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
          date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
          FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'
      

      but year without backquotes shouldn't throw the exception.

      Attachments

        Activity

          People

            Unassigned Unassigned
            maxgekk Max Gekk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: