Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6150

JDBC adapter for ClickHouse generates incorrect SQL for certain units in the EXTRACT function

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.36.0
    • 1.37.0
    • core

    Description

      Clickhouse does not support the following EXTRACT Unit syntax, and ClickHouseSqlDialect may need some adaptation.

       

      `SELECT EXTRACT(DOW FROM Date '2023-12-01')`

      Syntax error: failed at position 20 ('FROM'):

      SELECT EXTRACT(DOW FROM Date '2023-12-01');

      Expected one of: UUID, NOT, AND, BETWEEN, ILIKE, IN, OR, alias, Arrow, AS, LIKE, token, MOD, DIV, NOT LIKE, NOT ILIKE, NOT IN, GLOBAL IN, GLOBAL NOT IN, IS, Comma, Dot, QuestionMark, DoubleColon, end of query

       

      `SELECT EXTRACT(DOY FROM Date '2023-12-01')`

      Syntax error: failed at position 20 ('FROM'):

      SELECT EXTRACT(DOY FROM Date '2023-12-01');

      Expected one of: UUID, NOT, AND, BETWEEN, ILIKE, IN, OR, alias, Arrow, AS, LIKE, token, MOD, DIV, NOT LIKE, NOT ILIKE, NOT IN, GLOBAL IN, GLOBAL NOT IN, IS, Comma, Dot, QuestionMark, DoubleColon, end of query

       

      `SELECT EXTRACT(WEEK FROM Date '2023-12-01')`

      Exception on client:
      Code: 62. DB::Exception: The syntax 'EXTRACT(WEEK FROM date)' is not supported, cannot extract the number of a week

      Attachments

        1. image-2023-12-01-20-16-17-974.png
          21 kB
          ChenLuyang
        2. image-2023-12-01-20-16-48-298.png
          20 kB
          ChenLuyang
        3. image-2023-12-01-20-17-20-716.png
          26 kB
          ChenLuyang

        Activity

          People

            Unassigned Unassigned
            chen768959 ChenLuyang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: