Uploaded image for project: 'Kylin'
  1. Kylin
  2. KYLIN-4157

When using PrepareStatement query, functions within WHERE will cause InternalErrorException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Resolved
    • v2.6.3
    • v3.0.0-beta, v2.6.4
    • Query Engine
    • None

    Description

      Hi Kylin Team:

      I found a bug when I'm using PreparedStatement query.

      Let me use table KYLIN_SALES to explain the scenario.

      There is a SQL like:
      select LSTG_FORMAT_NAME, sum(PRICE) from KYLIN_SALES where lower(LSTG_FORMAT_NAME) = 'fp-gtc' group by LSTG_FORMAT_NAME

      In some cases, user doesn't know the LSTG_FORMAT_NAME is upper case or lower case, or they just want to query data ignoring cases.
      So assume they use lower(LSTG_FORMAT_NAME) = 'fp-gtc', it's a function within the filter.

      When I execute this SQL on Kylin web console, it can get the right result, but when I tried to execute it by PreparedStatement query on Postman, it threw InternalErrorException.

       

       

      ----------------------------------------------------------------------------

      Root Cause

      I debugged Kylin to find the root cause, it turns out when the filter contains function, compFilter.getColumn is null, and the compFilter.getFunction contains lower(LSTG_FORMAT_NAME), so that compFilter.getColumn().getType().isDateTimeFamily() will throw NullPointerException, that's the root cause for this 500 error.

       

      Solution

      I suggest to check nullable first before using compFilter.getColumn.

      Attachments

        1. image-2019-09-04-20-57-46-121.png
          460 kB
          Marc Wu
        2. image-2019-09-04-15-39-58-276.png
          631 kB
          Marc Wu
        3. image-2019-09-04-15-39-52-867.png
          237 kB
          Marc Wu

        Activity

          People

            mwu_ Marc Wu
            mwu_ Marc Wu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: