Giter Club home page Giter Club logo

Comments (7)

AndresNamm avatar AndresNamm commented on August 12, 2024 4

As I struggled a bit to understand the way with statements work, here is a full example

SELECT * FROM (
    with t1 as (select * FROM {{ref('other_dbt_view_or_table')}})
    SELECT * FROM t1
)

from dbt-athena.

Dandandan avatar Dandandan commented on August 12, 2024

Thanks, interesting find!

It would be good to find out in what cases Athena does support CTEs. Maybe we need to wrap the inner query in a select * from(with...? I am currently not on a computer, so I can not check.

from dbt-athena.

lukealexmiller avatar lukealexmiller commented on August 12, 2024

Ah, interesting, yes wrapping in the SELECT statement gets around the problem.
I'm generally using CTE's in (materialized) views in Athena with all CTE's preceding the final SELECT statement.

from dbt-athena.

Dandandan avatar Dandandan commented on August 12, 2024

Yeah, that makes sense, that's also how I use dbt generally.

We could likely change the adapter to wrap all queries in a select to workaround this issue.

from dbt-athena.

BeantownData avatar BeantownData commented on August 12, 2024

Thanks @AndresNamm !! That worked great!

from dbt-athena.

Dandandan avatar Dandandan commented on August 12, 2024

Maybe something that should be added to the docs while we don't workaround that Athena doesn't support it in a create table/view as statement?

from dbt-athena.

Dandandan avatar Dandandan commented on August 12, 2024

I believe we should just change the create_view_as and create_table_as macro's to generate a view starting with SELECT *.
Original macro's are here:

https://github.com/fishtown-analytics/dbt/blob/dev/marian-anderson/core/dbt/include/global_project/macros/adapters/common.sql

Help welcome!

from dbt-athena.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.