None value returned for sql_table_names from API

PatKearns
Participant I

Hi there,

We are pulling data from the Looker API and typically pull:

Models, then Explores.

I noticed today, when trying to get the `sql_table_name` from the joins (LookmlModelExploreJoins), that all the `sql_table_name`s are ‘None’.  

Example output:

 OrderedDict([('dependent_fields', ['dw_owl.customer_id', 'customer.id']),
('fields', None),
('foreign_key', None),
('from', None),
('outer_only', None),
('relationship', 'one_to_one'),
('required_joins', None),
('sql_foreign_key', None),
('sql_on', '${dw_owl.customer_id} = ${customer.id} '),
('sql_table_name', None),
('type', None),
('view_label', None),
('name', 'customer')]),
OrderedDict([('dependent_fields',
['customer.email', 'customer_dimension.email']),
('fields', None),
('foreign_key', None),
('from', None),
('outer_only', None),
('relationship', 'one_to_one'),
('required_joins', None),
('sql_foreign_key', None),
('sql_on', '${customer.email} = ${customer_dimension.email} '),
('sql_table_name', None),
('type', 'left_outer'),
('view_label', 'Customer'),
('name', 'customer_dimension')]),
OrderedDict([('dependent_fields',
['customer.email', 'dim_customers.customer_email']),
('fields', None),
('foreign_key', None),
('from', None),
('outer_only', None),
('relationship', 'many_to_one'),
('required_joins', None),
('sql_foreign_key', None),
('sql_on',
'${customer.email} = ${dim_customers.customer_email} '),
('sql_table_name', None),
('type', 'left_outer'),
('view_label', 'Customers (New)'),
('name', 'dim_customers')])]

Any help to fix that or another way to get all View sql_table_names would be greatly appreciated.

0 2 194
2 REPLIES 2

So, the reason these are “none” I believe is because there is a `sql_table_name` parameter at the join level, which can be used for overriding the view, but is rarely used in practice.

I don’t believe (last I checked) that there is a REST API method to get the view-level data. 

In case it helps, there are two open source LookML parsers (one in Python, and one in Node maintained by yours truly) that you might be able to use instead, if it’s possible for you to checkout the LookML directly via git. 

Also, in case you are trying to programmatically access the contents of a PDT, the `publish_as_db_view` LookML parameter can make that use case more convenient.

PatKearns
Participant I

Thanks for the reply @fabio1  !

Ah okay, yeah not interested in PDT contents, just trying to scrape out sql_table_names for some data lineage work.  

I’ll check out the Python parser.