Uploaded image for project: 'Tajo'
  1. Tajo
  2. TAJO-1667

TSql need to print obvious messages to specify SQL syntax errors.

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: SQL Parser
    • Labels:
      None

      Description

      Currently, Tsql doesn't print obvious messages to specify SQL syntax errors. I have tested Q19 query on TPC-H benchmark set as following:

      • Original Query
      select
          sum(l_extendedprice * (1 - l_discount) ) as revenue
      from
          lineitem,
          part
      where
      (
          p_partkey = l_partkey
          and p_brand = 'Brand#12'
          and p_container in ( 'SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
          and l_quantity >= 1 and l_quantity <= 1 + 10
          and p_size between 1 and 5
          and l_shipmode in ('AIR', 'AIR REG')
          and l_shipinstruct = 'DELIVER IN PERSON'
      )
      or
      (
          p_partkey = l_partkey
          and p_brand = 'Brand#23'
          and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
          and l_quantity >= 10 and l_quantity <= 10 + 10
          and p_size between 1 and 10
          and l_shipmode in ('AIR', 'AIR REG')
          and l_shipinstruct = 'DELIVER IN PERSON'
      )
      or
      (
          p_partkey = l_partkey
          and p_brand = 'Brand#34'
          and p_container in ( 'LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
          and l_quantity >= 20 and l_quantity <= 20 + 10
          and p_size between 1 and 15
          and l_shipmode in ('AIR', 'AIR REG')
          and l_shipinstruct = 'DELIVER IN PERSON'
      );
      
      • Wrong Query 1
      select
          sum(l_extendedprice * (1 - l_discount) ) as revenue
      from
          lineitem,
          part
      where
      (
          p_partkey = l_partkey
          and p_brand = 'Brand#12'
          and p_container in ( 'SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
          and l_quantity >= 1 and l_quantity <= 1 + 10
          and p_size between 1 and 5
          and l_shipmode in ('AIR', 'AIR REG')
          and l_shipinstruct = 'DELIVER IN PERSON'
      )
      or
      (
          p_partkey = l_partkey
          and p_brand = 'Brand#23'
          and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
          and l_quantity >= 10 and l_quantity <= 10 + 10
          and p_size between 1 and 10
          and l_shipmode in ('AIR', 'AIR REG'))
          and l_shipinstruct = 'DELIVER IN PERSON'
      )
      or
      (
          p_partkey = l_partkey
          and p_brand = 'Brand#34'
          and p_container in ( 'LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
          and l_quantity >= 20 and l_quantity <= 20 + 10
          and p_size between 1 and 15
          and l_shipmode in ('AIR', 'AIR REG')
          and l_shipinstruct = 'DELIVER IN PERSON'
      );
      

      I just put a parenthesis to above query at line 23. But Tsql printed error messages as follows.

      ERROR: syntax error at or near ''DELIVER IN PERSON''
      LINE 24:25     and l_shipinstruct = 'DELIVER IN PERSON'
      
      • Wrong Query 2
      select
          sum(l_extendedprice * (1 - l_discount) ) as revenue
      from
          lineitem,
          part
      where
      (
          p_partkey = l_partkey
          and p_brand = 'Brand#12'
          and p_container in ( 'SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
          and l_quantity >= 1 and l_quantity <= 1 + 10
          and p_size between 1 and 5
          and l_shipmode in ('AIR', 'AIR REG')
          and l_shipinstruct = 'DELIVER IN PERSON'
      )
      or
      (
          p_partkey = l_partkey
          and p_brand = 'Brand#23'
          and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
          and l_quantity >= 10 and l_quantity <= 10 + 10
          and p_size between 1 and 10
          and l_shipmode in ('AIR', 'AIR REG')
          and l_shipinstruct = 'DELIVER IN PERSON'
      )
      or
      (
          p_partkey = l_partkey
          and p_brand = 'Brand#34'
          and p_container in ( 'LG CASE', 'LG BOX', 'LG PACK', 'LG PKG',
      )
          and l_quantity >= 20 and l_quantity <= 20 + 10
          and p_size between 1 and 15
          and l_shipmode in ('AIR', 'AIR REG')
          and l_shipinstruct = 'DELIVER IN PERSON'
      );
      

      I just added a comma to above query at line 30. But Tsql printed error messages as follows.

      ERROR: syntax error at or near 'or'
      LINE 26:0 or
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              blrunner JaeHwa Jung
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: