Uploaded image for project: 'Hue (READ ONLY)'
  1. Hue (READ ONLY)
  2. HUE-9477

[indexer] SQL code formatting errors with StopIteration with Python 3

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.7.0
    • Fix Version/s: None
    • Component/s: app.querybrowser, ui
    • Labels:
      None

      Description

      Clicking on the format code button in the SQL Editor errors when using Python 3.8

      generator raised StopIteration
      
      [23/Aug/2020 23:11:57 -0700] decorators   ERROR    Error running format
      Traceback (most recent call last):
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/filters/reindent.py", line 31, in _flatten_up_to_token
          raise StopIteration
      StopIteration
      
      The above exception was the direct cause of the following exception:
      
      Traceback (most recent call last):
        File "/home/romain/projects/hue/desktop/libs/notebook/src/notebook/decorators.py", line 119, in wrapper
          return f(*args, **kwargs)
        File "/home/romain/projects/hue/desktop/libs/notebook/src/notebook/api.py", line 803, in format
          response['formatted_statements'] = sqlparse.format(statements, reindent=True, keyword_case='upper') # SQL only currently
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/__init__.py", line 60, in format
          return ''.join(stack.run(sql, encoding))
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/engine/filter_stack.py", line 39, in run
          filter_.process(stmt)
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/filters/reindent.py", line 155, in process
          self._process(stmt)
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/filters/reindent.py", line 95, in _process
          func(tlist)
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/filters/reindent.py", line 151, in _process_default
          [self._process(sgroup) for sgroup in tlist.get_sublists()]
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/filters/reindent.py", line 151, in <listcomp>
          [self._process(sgroup) for sgroup in tlist.get_sublists()]
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/filters/reindent.py", line 95, in _process
          func(tlist)
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/filters/reindent.py", line 118, in _process_identifierlist
          num_offset = 1 if self.char == '\t' else self._get_offset(first)
        File "/home/romain/projects/hue/build/env/lib/python3.8/site-packages/sqlparse/filters/reindent.py", line 39, in _get_offset
          raw = ''.join(map(text_type, self._flatten_up_to_token(token)))
      RuntimeError: generator raised StopIteration
      

       

        Attachments

          Activity

            People

            • Assignee:
              ayush.goyal Ayush Kumar Goyal
              Reporter:
              ayush.goyal Ayush Kumar Goyal
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: