parse_drop silently discards TEMPORARY and PERSISTENT for most object types

Đang mở
#2,779 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust, sql
Lĩnh vực
compilers

Hướng nghiên cứu

Start in src/parser/mod.rs at Parser::parse_drop, where TEMPORARY and PERSISTENT are consumed before the object type is read. Use the existing Statement::Drop and DROP SECRET branches, which keep these flags, as the model. Done means DROP TEMPORARY FUNCTION keeps its flag in a dialect that supports it, and the other object types reject the keyword with a parse error. Check the dialect tests for MySQL, Generic and DuckDB.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Databricks DuckDB Hive MySQL Spark

parse_drop consumes TEMPORARY (MySQL, Generic, DuckDB) and PERSISTENT (DuckDB) before it reads the object type. Only Statement::Drop and DROP SECRET keep these flags. Every other branch drops them, so the statement parses without error but loses the keyword when printed:

Input Dialect Output
DROP TEMPORARY FUNCTION f Generic DROP FUNCTION f
DROP TEMPORARY TRIGGER tr ON t Generic DROP TRIGGER tr ON t
DROP TEMPORARY PROCEDURE p Generic DROP PROCEDURE p
DROP PERSISTENT TABLE t DuckDB DROP TABLE t

The same applies to POLICY, CONNECTOR, DOMAIN, EXTENSION and OPERATOR.

In most cases the input isn't valid SQL anyway, so it should fail instead of being accepted. DROP TEMPORARY FUNCTION is real syntax in Spark/Databricks and Hive, so there the parser drops meaningful information.

Expected

Reject TEMPORARY/PERSISTENT for object types that don't support them, and keep the flag where a dialect does support it, e.g. DROP TEMPORARY FUNCTION.

Code

src/parser/mod.rs, Parser::parse_drop

Spotted while reviewing #2434

Ngôn ngữ chính
Rust
Star
3.5k
Fork
805
Merge trung bình
2 ngày 3 giờ
Pull request đã merge (30 ngày)
116

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/datafusion-sqlparser-rs

Tất cả issue của apache/datafusion-sqlparser-rs

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.