timkessler edited a comment on issue #4192: sql_lab.py is using the raw dbapi 
connection object and not SQLAlchemy dialect
URL: 
https://github.com/apache/incubator-superset/issues/4192#issuecomment-424148215
 
 
   @tomasienrbc  I've got this working for me.  I'm dumping my full notes here. 
 Pay special attention to "MODIFY SUPERSET CODE FILES" section.  This section 
reshapes values to fit in superset.  If I understand correctly, the changes 
that I made to dataframe.py may need to be refactored into db_engines_spec.py
   
   
   # Install DREMIO connectors on Ubuntu 
   ### Install unixodbc - prerequisite to dremio-odbc
   sudo apt-get install unixodbc-dev unixodbc-bin unixodbc
   
   ### Install dremio-odbc 
   curl -o dremio-odbc-1.3.19.1052-1.x86_64.rpm 
https://download.dremio.com/odbc-driver/1.3.19.1052/dremio-odbc-1.3.19.1052-1.x86_64.rpm
   sudo apt-get install alien
   sudo alien -i dremio-odbc-1.3.19.1052-1.x86_64.rpm 
   
   # Build sqlalchemy_dremio 
   
   ###clone sqlalchemy_dremio dialect repository:
   git clone https://github.com/sqggles/sqlalchemy_dremio.git
   cd sqlalchemy 
   make clean
   
   ### build source and wheel package.  The make file referenced python2, so I 
pulled the commands out and changed to python3:
   python3 setup.py sdist
   python3 setup.py bdist_wheel
   ls -l dist
   
   ### run tests
   python3 sqlalchemy_dremio/tests/conftest.py 
   
   
   ### install the package to the active python3's site-packages
   python3 setup.py install
   
   
   #  MODIFY SUPERSET CODE FILES 
   
   superset/sql_lab.py:  
   import sqlalchemy_dremio.pyodbc #add this line below import sqlalchemy
   
   superset/dataframe.py:
   
   Change from:
           self.column_names = dedup(
               db_engine_spec.get_normalized_column_names(cursor_description))
   
           data = data or []
   
           self.df = (
               pd.DataFrame(list(data), columns=column_names).infer_objects())
   
   Change to:
           self.column_names = dedup(
               db_engine_spec.get_normalized_column_names(cursor_description))
   
           data = data or []
   
           #customized:
           colcount = len(column_names)
           rowcount = len(data)
           data = np.reshape(data, (rowcount, colcount))
   
           self.df = (
               pd.DataFrame(list(data), columns=column_names).infer_objects())
   
   # RESTART SUPERSET
   systemctl restart superset.service
   
   #  DREMIO ADMIN 
   Login to dremio.
   Create user in dremio.
   
   # Create Datasource in Superset 
   Create database connection with URI example below.  See 
sqlalchem_dremio/tests/test_sql_alchemy_dremio.py for more info.  I used:
   dremio+pyodbc://user:password@dremioipaddress:31010/mydremiodatasourcename
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to