sql-parser icon indicating copy to clipboard operation
sql-parser copied to clipboard

Add support for three-part column references

Open malensek opened this issue 5 months ago • 1 comments

This adds support for three-part column references:

SELECT schema.table.column FROM table;

So something like SELECT catalog.students.grade FROM students; will populate the schema field in Expr:

expr->schema = "catalog";
expr->table = "students";
expr->name = "grade";

The changes are fairly light:

  • Added a grammar entry for IDENTIFIER '.' IDENTIFIER '.' IDENTIFIER
  • Added Expr::makeColumnRef(char* schema, char* table, char* name)
  • Added a test case covering this scenario

I have confirmed this passes the test suite and leak test on Linux 6.18.35-1-lts and test suite on macOS 26.5.1. I also see that the repo has the Bison output checked in so I did so as well for this PR, but please let me know if I should exclude it or need to run with the same version of Bison that was previously used to generate the files.

Thanks for this great library, it's very clean and easy to work with!

malensek avatar Jun 11 '26 07:06 malensek

Thanks a lot for reviewing this -- just updated the PR with the changes. Let me know if I can tweak this more.

malensek avatar Jun 15 '26 18:06 malensek