Comments (3)
I can confirm that, while disappointing, this is the expected behaviour of the parameter escaping.
Since the Spark thrift server doesn't support parameterised SQL (yet) the implementation makes a best effort to escape inputs as strings. But table names in Spark SQL cannot be string literals. The way parameter escaping works right now it will only write valid SQL as part of a WHERE clause. This is a consequence of trying to implement in the client what should instead be (and eventually will be) implemented by the server.
from databricks-sql-python.
Ok, that's a bummer. Thank you for the quick response.
I got the example from the code comments, look at:
databricks-sql-python/src/databricks/sql/client.py
Lines 460 to 462 in 258b961
It is not technically wrong, since it does result in that SQL query, but it is an invalid query.
Do you think using SQLAlchemy would help me on this use case?
from databricks-sql-python.
Thanks for noting the bad example! I've opened a PR to fix that example to be more accurate.
It is not technically wrong, since it does result in that SQL query, but it is an invalid query.
Agreed.
Do you think using SQLAlchemy would help me on this use case?
It depends! If you're just using basic SQLAlchemy primitives like engine.execute(sqlalchemy.text("...query text..").bindparams(some_param=some_value))
then it will behave exactly like the raw DBAPI driver and will fail.
But if you are using SQLAlchemy's ORM capabilities to define your models ahead of time, then it will know how to write the table names without escaping.
For example:
class SampleObject1base):
__tablename__ = "mySampleTable1"
name = Column(String(255), primary_key=True)
episodes = Column(Integer)
some_bool = Column(BOOLEAN)
class SampleObject2base):
__tablename__ = "mySampleTable2"
name = Column(String(255), primary_key=True)
episodes = Column(Integer)
some_bool = Column(BOOLEAN)
for model in [SampleObject1, SampleObject2]:
model.select().all()
SQLAlchemy will emit these statements:
select * from mySampleTable1
select * from mySampleTable2
from databricks-sql-python.
Related Issues (20)
- Insert performance is woeful! 😢 HOT 11
- cursor.execute returing error 'NoneType' object is not iterable HOT 15
- [Document] Support databricks-cli authentication HOT 1
- Dash/Minus in column name causes UNBOUND_SQL_PARAMETER in bind values HOT 2
- Extremely slow import times on Python 3.12 HOT 9
- [sqlalchemy] execute("select 1") gives TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType' HOT 8
- `databricks.sql.connect` hangs in a long retrying loop when an invalid access token is used HOT 3
- Idea: arrow_record_batches cursor method
- SQLAlchemy engine from workspace level service principle? HOT 2
- Unable to write list/array type data HOT 2
- Issue with version 3.1.1
- Failure on cursor.fetchall() HOT 2
- Fixing a couple type problems. (adding py.typed, typing connect, returning Any from fetchall (which I failed to fix!)) HOT 2
- Connector reads 0 rows although Cluster returned results HOT 18
- support new Cursor attribute that provides information on completed commands HOT 1
- loosen, update, or widen pyarrow dependencies HOT 2
- ImportError: cannot import name 'sql' from partially initialized module 'databricks' HOT 2
- Unpin Thrift
- Original thrift file HOT 3
- Invalid SessionHandle Error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from databricks-sql-python.