-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnboundLocalError: local variable 'i' referenced before assignment #463
Comments
@mggger hi, did you solved this issue? |
https://github.com/dropbox/PyHive/blob/master/pyhive/sqlalchemy_hive.py#L369 def get_indexes(self, connection, table_name, schema=None, **kw):
rows = self._get_table_columns(connection, table_name, schema)
# Strip whitespace
rows = [[col.strip() if col else None for col in row] for row in rows]
# Filter out empty rows and comment
rows = [row for row in rows if row[0] and row[0] != '# col_name']
for i, (col_name, _col_type, _comment) in enumerate(rows):
if col_name == '# Partition Information':
break
# Handle partition columns
col_names = []
for col_name, _col_type, _comment in rows[i + 1:]:
col_names.append(col_name)
if col_names:
return [{'name': 'partition', 'column_names': col_names, 'unique': False}]
else:
return [] i is not declare |
i change code to and problem is ok def get_indexes(self, connection, table_name, schema=None, **kw):
rows = self._get_table_columns(connection, table_name, schema)
# Strip whitespace
rows = [[col.strip() if col else None for col in row] for row in rows]
# Filter out empty rows and comment
rows = [row for row in rows if row[0] and row[0] != '# col_name']
index = -1
for i, (col_name, _col_type, _comment) in enumerate(rows):
if col_name == '# Partition Information':
index = i
break
# Handle partition columns
col_names = []
if index != -1:
for col_name, _col_type, _comment in rows[index + 1:]:
col_names.append(col_name)
if col_names:
return [{'name': 'partition', 'column_names': col_names, 'unique': False}]
else:
return [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I have met some errors:
The text was updated successfully, but these errors were encountered: