TypeError: expected string or bytes-like object

Open
#415 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, sqlalchemy
Domain
databases

Research direction

Start in pyhive/sqlalchemy_hive.py at HiveDialect.get_columns, especially the parsing around line 324, and reproduce the failure with the supplied Hive schema containing a newline in a column comment. Check the existing SQLAlchemy dialect tests for get_columns; done means reflection no longer raises TypeError for this schema and returns the column metadata.

Written by the indexing model from the issue text.

Description

my hive table comment contain '\n'

hive schema:
CREATE EXTERNAL TABLE test.test_01( name string COMMENT 'aa bb\ncc');
pyhive rows:
['name', 'string', 'aa bb
cc']

TypeError: expected string or bytes-like object
File "/usr/lib/python3.6.14/lib/python3.6/site-packages/pyhive/sqlalchemy_hive.py", line 324, in get_columns
311 def get_columns(self, connection, table_name, schema=None, **kw):
(...)
320 break
321 # Take out the more detailed type information
322 # e.g. 'map<int,int>' -> 'map'
323 # 'decimal(10,1)' -> decimal
--> 324 col_type = re.search(r'^\w+', full_col_type).group(0)
325 try:
..................................................
self = <pyhive.sqlalchemy_hive.HiveDialect object at 0x7ff3fd0d2cc0>
connection = <sqlalchemy.engine.base.Connection object at 0x7ff3cad2e0b8>
table_name = 'ewsgz_ods_pck_info'
schema = 'hudi'
kw = {'info_cache': {}}
col_type = 'bigint'
re.search = <function 'search' re.py:179>
full_col_type = None
..................................................

File "/usr/lib/python3.6.14/lib/python3.6/re.py", line 182, in search
179 def search(pattern, string, flags=0):
180 """Scan through string looking for a match to the pattern, returning
181 a match object, or None if no match was found."""
--> 182 return _compile(pattern, flags).search(string)
..................................................
pattern = '^\w+'
string = None
flags = 0

Dominant language
Python
Stars
1.7k
Forks
545
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dropbox/PyHive

All issues in dropbox/PyHive

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.