DATEPART Function fails if you use text('YEAR') instead of 'YEAR'
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Reproduce the DATEPART(text('YEAR'), table_date.c['date_field']) example against the Databricks dialect and inspect the dialect's compilation path for DATEPART. Compare it with DATEPART('YEAR', ...) to identify how text('YEAR') is rendered; done means the text form compiles and executes without treating YEAR as an invalid quoted identifier.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Overview
When I attempt to use a datepart function with text('YEAR'), the compile code for the databricks dialect throws and error (see sample code below as it is trying to treat the text part as a quoted identifier common to databricks `.
Environment Information
OS = Windows 2022 Server
Python Version = 3.10.2
Python Package Versions
- sqlalchemy=1.4.48
- databricks-sql-connector=2.5.2
Code Sample
from configparser import ConfigParser
from pathlib import Path
from sqlalchemy import create_engine, Identity
from sqlalchemy.orm import Session
from sqlalchemy.engine import URL
from sqlalchemy.schema import Table, Column, MetaData, CreateTable
from sqlalchemy.sql.sqltypes import BIGINT, VARCHAR, DATE
from sqlalchemy.sql.expression import func, and_, or_, text, distinct, insert, union_all
config_path = Path.home() / '.databrickscfg'
config = ConfigParser()
config.read(config_path)
token = config['DEFAULT']['token']
url_info = {
'drivername': 'databricks',
'username': 'token',
'password': token,
'host': config['DEFAULT']['host'].replace('https://', '').replace('/', ''),
'port': 43,
'database': 'curv'
}
catalog = config['DEFAULT']['catalog']
http_path = "/sql/1.0/warehouses/3c0fbf823204df89"
url = URL.create(
**{key: value for key, value in url_info.items()},
query={'http_path': http_path, 'catalog': catalog}
)
engine = create_engine(url=url,
pool_pre_ping=1)
session = Session(engine)
table_date = Table(
'test_date',
MetaData(),
Column('date_field', DATE, nullable=False)
)
table_date.create(bind=engine)
table_date.insert().values(date_field='2019-02-12')
query = session.query(func.DATEPART(text('YEAR'), table_date.c['date_field']).label('date_field'))
session.execute(query)
- Ngôn ngữ chính
- Python
- Star
- 233
- Fork
- 152
- Merge trung bình
- 21 giờ 5 phút
- Pull request đã merge (30 ngày)
- 10
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của databricks/databricks-sql-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Tất cả issue của databricks/databricks-sql-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
PolicyEngine/policyengine-us#9559 ·
-
priority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
googleapis/librarian#7636 ·
-
from:qa priority:P2 reliability tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
spec-kitty/spec-kitty#4874 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100