Support Questions

Find answers, ask questions, and share your expertise

python hivejdbc returns null values after first null column

avatar
New Contributor

When running the query 'select cola, null as colb, "x" as colc from mytable' it gives the results:

 

cola, colb, colc

0001, None, None

None, None, None,
None, None, None

 

etc.

 

Using hivejdbc and python 3

Source:

 

 

#!/usr/bin/python3

import hivejdbc
from hivejdbc import connect, DictCursor
conn = connect(
  host='$$$$$$.$$$$.$$$$',
  port=10000,
  driver='/PATH/hivejdbc42',
  ssl=True,
  trust_store='/truststore.jks',
  trust_password='PASSWORD',
  principal='hive/$$$$.$$$$.$$$$',
  database='default',
)
try:
  cur = conn.cursor()
  cur.execute('select cola, null as colb, "x" as colc from mytable')
  result = cur.fetchall()
  print(result)
  cur.close()
except:
  print("Something went wrong!")
  sys.exit("Error")

 

 

2 REPLIES 2

avatar
Expert Contributor

@Geenspruitjes 

Was the below query working in hs2 beeline ?

'select cola, null as colb, "x" as colc from mytable'

Can you share the show create table output.

show create table <tablename>;

avatar
Community Manager

@Geenspruitjes, Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future.  If you are still experiencing the issue, can you provide the information @balajip has requested?



Regards,

Vidya Sargur,
Community Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community: