question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing 3 part table names

See original GitHub issue

Hello, is it possible for me to configure sqllineage to understand 3 part (database.schema.table) formatted names? My queries reference all tables in this format but the output is not as expected for them, it’s only getting the first 2 parts which are the database and schema. Thanks for any feedback or advice here.

Example vs expected output below:

sqllineage -e "CREATE OR REPLACE TABLE dbname.schemaname.tablename AS SELECT o.* FROM dbn.scn.orders o JOIN dbn.scn.users u ON o.id = u.id;"
Statements(#): 1
Source Tables:
    dbn.scn
Target Tables:
    dbname.schemaname

Expected source tables:

dbn.scn.orders
dbn.scn.users

Expected target table: dbname.schemaname.tablename

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jlin83commented, Jun 3, 2021

FWIW - Redshift has the same convention

1reaction
reatacommented, Jun 3, 2021

I actually think this is an interesting use case given Snowflake as a data warehouse solution supports this. Let me check if there’s anything I can do.

I think the bottom line is, for a table named as db.schema.tbl, the last thing we would give end user as full table name is db.schema. No doubt db.schema.tbl as full name is the desired answer, but at least we should try give end user schema.tbl.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parsing Table Names from SQL - Gregory Trubetskoy
In SQL table names always follow the FROM and JOIN keywords. So all you have to do is split the statemement into tokens,...
Read more >
JR60788: DB2 Connector fails while parsing 3-part table name
DB2 Connector code has been altered so the table name in SQL query containing database and schema is properly parsed. Temporary fix. Comments ......
Read more >
Parse table names from a bunch SQL statements
SQL> ed Wrote file afiedt.buf 1 SELECT table_owner, table_name 2 FROM dba_indexes 3 WHERE owner = 'SCOTT' 4* AND index_name = 'PK_DEPT' SQL> ......
Read more >
Parsing SQL for Table Names - SQLServerCentral
Recently I've discovered another useful SQL parser called MacroScope ... script for finding all table names and aliases within a SQL string:
Read more >
Extracting Table Names, Dataset From SQL Queries - Medium
How to use Python to extract datasets and table names from plaintext SQL queries.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found