Hi, need help to factor the data catalog. Below ar...
# questions
a
Hi, need help to factor the data catalog. Below are the SQL definitions
Copy code
"B.trade":
 type: pandas.SQLQueryDataset
 sql: "select * from YTB"

"A.trade":
 type: pandas.SQLQueryDataset
 sql: "select * from RET"
And I want to factor the above in data catalog based on the namespace. But not quite sure how to associate each namespace with the right table name. Thanks!
Copy code
"{namespace}.trade":
 type: pandas.SQLQueryDataset
 sql: "select * from ??"
m
The placeholders don't matter, they are just patterns (think of capture groups from regular expressions. With definition as:
Copy code
"{namespace}.trade":
 type: pandas.SQLQueryDataset
 sql: "select * from {namespace}"
Whenever you will use something like
"A.trade"
as dataset name in your Kedro pipeline it will effectively be as if you had defined:
Copy code
"A.trade":
 type: pandas.SQLQueryDataset
 sql: "select * from A"
a
@marrrcin since the table names do not follow the namespace placeholders, is there a way to associate each namespace with a different table name? So if the namespace is A, table should be YTB if the namespace is B, table should be RET
j
maybe you can add a custom mapping on top:
Copy code
_mappings:
  A: YTB
  B: RET

"{namespace}.trade":
  type: ...
  sql: "select * from ${_mappings[namespace]}"
I have not tried this and have no idea if it works
🤔 2
m
If all other suggestions will not work, there's always a custom resolver option (https://docs.kedro.org/en/stable/configuration/advanced_configuration.html#how-to-use-resolvers-in-the-omegaconfigloader)
K 1
a
we decided to just rename/create copy of the SQL tables using the namespace instead! 😀 namespace wins 😆