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

Incomplete validation of operands in JSON functions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.20.0
    • None
    • core

    Description

      The operands of various JSON functions are not validated correctly. 

      Consider for instance the JSON_VALUE function and the following calls:

      json_value('{\"foo\":100}', 'strict $.foo')"
      json_value(1, 'strict $.foo')"
      json_value(TRUE, 'strict $.foo')"
      

      The first call is legal but the next are not; if I am not wrong the operands should be always CHAR or VARCHAR literals which is not the case above.

      Queries involving such calls fail at runtime when compiling generated code. I guess that such kind of problems should be captured by the validator and we should not even arrive at the code generation step.

      The problems can be easily reproduced by adding such calls in the SqlOperatorBaseTest.

      The problem does not only affect JSON_VALUE but other JSON functions (such as JSON_QUERY etc.) as well.

      Attachments

        Issue Links

          Activity

            People

              wangm92 Matt Wang
              zabetak Stamatis Zampetakis
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m