Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.3.2 SHOW CREATE TABLE doesn't fetch values #61

Closed
Barsoomx opened this issue Oct 21, 2022 · 3 comments · Fixed by #60 or #62
Closed

v0.3.2 SHOW CREATE TABLE doesn't fetch values #61

Barsoomx opened this issue Oct 21, 2022 · 3 comments · Fixed by #60 or #62
Labels
bug Something isn't working

Comments

@Barsoomx
Copy link
Contributor

Since v0.3.2, SHOW CREATE TABLE doesn't fetch any values via dbt load_result()

image

Steps to reproduce:

Macros:

{% macro show_create_table2(relation) %}
    {% call statement('show_create_table', fetch_result=True) %}
        SELECT
            create_table_query AS ddl
        FROM system.tables
        WHERE
            name = '{{ relation.identifier }}' AND
            database = '{{ relation.schema }}'
    {% endcall %}

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


{% macro show_create_table3(relation) %}
    {% call statement('show_create_table', fetch_result=True) %}
        SHOW CREATE TABLE {{ relation.schema }}.{{ relation.identifier }}
    {% endcall %}

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

then in python console:

import os
import time
from clickhouse_connect.driver import HttpClient
from dbt.adapters.clickhouse import ClickHouseAdapter, ClickHouseRelation
from dbt.adapters.factory import get_adapter_by_type
from dbt.contracts.connection import Connection
from dbt.contracts.relation import Path
from dbt.lib import get_dbt_config
from dbt.tests.util import get_connection
config = get_dbt_config('/usr/app/')
ch_adapter = ClickHouseAdapter(config)
adapter = get_adapter_by_type(ch_adapter.type())
with get_connection(adapter) as conn:
    rel=adapter.get_relation(None, 'internal_analytics_src', 'src_dsas_datasources')
t1=adapter.execute_macro('show_create_table2', kwargs={"relation":rel})
t2=adapter.execute_macro('show_create_table3', kwargs={"relation":rel})

t2 is empty here, should be a table
image

I assume this is due to Handle queries that are actually commands, simply and clean up tests

But this command should load a table value, and it's counter-intuitive why it doesn't now.

@Barsoomx
Copy link
Contributor Author

tagging @genzgd, dbt relevant)

This was linked to pull requests Oct 21, 2022
@genzgd
Copy link
Collaborator

genzgd commented Oct 21, 2022

@Barsoomx This should be fixed in 0.3.3.

I'm curious as to how this is dbt relevant. I don't see any use of SHOW CREATE TABLE in DBT, am I missing something?

@genzgd genzgd closed this as completed Oct 21, 2022
@Barsoomx
Copy link
Contributor Author

No, I thought it's relevant because of load_result. The macro I showed you is in dbt, albeit it's mine, sorry for the confusion, there's no such code in base dbt

@genzgd genzgd added the bug Something isn't working label Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants