Skip to content

Commit

Permalink
Renaming macro and method name
Browse files Browse the repository at this point in the history
On second look I wasn't happy with my name choices for macro name and
method, hopefully what I have now makes more sense.

[CT-276] Apache Iceberg Support dbt-labs#294
  • Loading branch information
dparent1 authored and cccs-jc committed Nov 19, 2022
1 parent 3d6d5bd commit b3bc8a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions dbt/adapters/spark/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
GET_COLUMNS_IN_RELATION_RAW_MACRO_NAME = "get_columns_in_relation_raw"
LIST_SCHEMAS_MACRO_NAME = "list_schemas"
LIST_RELATIONS_MACRO_NAME = "list_relations_without_caching"
LIST_RELATIONS_NO_EXTENDED_MACRO_NAME = "list_relations_without_caching_no_extended"
LIST_RELATIONS_SHOW_TABLES_MACRO_NAME = "list_relations_show_tables_without_caching"
DESCRIBE_TABLE_EXTENDED_MACRO_NAME = "describe_table_extended_without_caching"
DROP_RELATION_MACRO_NAME = "drop_relation"
FETCH_TBL_PROPERTIES_MACRO_NAME = "fetch_tbl_properties"
Expand Down Expand Up @@ -128,7 +128,7 @@ def add_schema_to_cache(self, schema) -> str:
# so jinja doesn't render things
return ""

def use_show_tables(self, table_name):
def parse_information(self, table_name):
information = ""
kwargs = {"table_name": table_name}
try:
Expand Down Expand Up @@ -166,7 +166,7 @@ def list_relations_without_caching(
if try_show_tables:
expected_result_rows = 3
try:
results = self.execute_macro(LIST_RELATIONS_NO_EXTENDED_MACRO_NAME, kwargs=kwargs)
results = self.execute_macro(LIST_RELATIONS_SHOW_TABLES_MACRO_NAME, kwargs=kwargs)
except dbt.exceptions.RuntimeException as e:
errmsg = getattr(e, "msg", "")
description = "Error while retrieving information about"
Expand All @@ -186,7 +186,7 @@ def list_relations_without_caching(

if try_show_tables:
_, name, _ = row
information = self.use_show_tables(name)
information = self.parse_information(name)
_schema = schema_relation.schema
else:
_schema, name, _, information = row
Expand Down
8 changes: 3 additions & 5 deletions dbt/include/spark/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,18 @@
{% do return(load_result('list_relations_without_caching').table) %}
{% endmacro %}

{% macro list_relations_without_caching_no_extended(schema_relation) %}
{#-- We can't use temporary tables with `create ... as ()` syntax #}
{% macro list_relations_show_tables_without_caching(schema_relation) %}
{#-- Spark with iceberg tables don't work with show table extended for #}
{#-- V2 iceberg tables #}
{#-- https://issues.apache.org/jira/browse/SPARK-33393 #}
{% call statement('list_relations_without_caching_no_extended', fetch_result=True) -%}
{% call statement('list_relations_without_caching_show_tables', fetch_result=True) -%}
show tables in {{ schema_relation }} like '*'
{% endcall %}

{% do return(load_result('list_relations_without_caching_no_extended').table) %}
{% do return(load_result('list_relations_without_caching_show_tables').table) %}
{% endmacro %}

{% macro describe_table_extended_without_caching(table_name) %}
{#-- We can't use temporary tables with `create ... as ()` syntax #}
{#-- Spark with iceberg tables don't work with show table extended for #}
{#-- V2 iceberg tables #}
{#-- https://issues.apache.org/jira/browse/SPARK-33393 #}
Expand Down

0 comments on commit b3bc8a4

Please sign in to comment.