Giter VIP home page Giter VIP logo

Comments (1)

jtcohen6 avatar jtcohen6 commented on May 20, 2024

@rjh336 Thanks for opening the issue!

The reason these values are missing for SELECT + UPDATE statements is because we don't have logic to handle those statement types within execute:

message = 'OK'
code = None
num_rows = None
bytes_processed = None
if query_job.statement_type == 'CREATE_VIEW':
code = 'CREATE VIEW'
elif query_job.statement_type == 'CREATE_TABLE_AS_SELECT':
conn = self.get_thread_connection()
client = conn.handle
query_table = client.get_table(query_job.destination)
code = 'CREATE TABLE'
num_rows = query_table.num_rows
num_rows_formated = self.format_rows_number(num_rows)
bytes_processed = query_job.total_bytes_processed
processed_bytes = self.format_bytes(bytes_processed)
message = f'{code} ({num_rows_formated} rows, {processed_bytes} processed)'
elif query_job.statement_type == 'SCRIPT':
code = 'SCRIPT'
bytes_processed = query_job.total_bytes_processed
message = f'{code} ({self.format_bytes(bytes_processed)} processed)'
elif query_job.statement_type in ['INSERT', 'DELETE', 'MERGE']:
code = query_job.statement_type
num_rows = query_job.num_dml_affected_rows
num_rows_formated = self.format_rows_number(num_rows)
bytes_processed = query_job.total_bytes_processed
processed_bytes = self.format_bytes(bytes_processed)
message = f'{code} ({num_rows_formated} rows, {processed_bytes} processed)'
response = BigQueryAdapterResponse(
_message=message,
rows_affected=num_rows,
code=code,
bytes_processed=bytes_processed
)
return response, table

We totally could! From a little poking around, I think:

  • UPDATE should be a simple addition to the conditional branch that includes ['INSERT', 'DELETE', 'MERGE']
  • SELECT needs its own new conditional branch, which might look something like:
        elif query_job.statement_type == 'SELECT':
            code = 'SELECT'
            bytes_processed = query_job.total_bytes_processed
            
            # these are internal properties, so we should be cautious
            # maybe more trouble than it's worth?
            if (
                hasattr(query_job, '_query_results') 
                and hasattr(query_job._query_results, '_properties')
                and hasattr(query_job._query_results._properties, 'get')
            ):
                num_rows = query_job._query_results._properties.get('totalRows')

I'm going to mark this a good first issue, and I'd welcome a PR to add those in :)

from dbt-bigquery.

Related Issues (20)

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.