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

max_results parameter is not working #169

Open
Kulkarnionkar2007 opened this issue Mar 24, 2023 · 1 comment · May be fixed by #263
Open

max_results parameter is not working #169

Kulkarnionkar2007 opened this issue Mar 24, 2023 · 1 comment · May be fixed by #263
Labels
bug Something isn't working

Comments

@Kulkarnionkar2007
Copy link

Hello Goccy,

Recently came across a bug/issue where noticed that max_results parameter is not working which we generally use to set/get max total no. of records from query job. Below mentioned is sample code which returns all records from table (no effect of max_results parameter)

import typing
from typing import Union
from google.auth.credentials import AnonymousCredentials
from google.api_core.client_options import ClientOptions

if typing.TYPE_CHECKING:
from google.cloud.bigquery import LoadJob, CopyJob, ExtractJob, QueryJob

def create_job() -> "Union[LoadJob, CopyJob, ExtractJob, QueryJob]":
# [START bigquery_create_job]
from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client(
    "dummy-local",
    client_options=ClientOptions(api_endpoint="http://bigquery:9050"),
    credentials=AnonymousCredentials(),
)

query_job = client.query("""
                     SELECT id,percent,name,bq_decrypt_data(name) as dname
                     FROM `dummy-local.dataset1.table_csv`
                     """)  # Make an API request.
result = query_job.results(max_results=1)
for row in result:
    print(str(row))

print(create_job())

Could you help to fix it please.

Best Regards,
Onkar Kulkarni

@goccy goccy added the bug Something isn't working label May 4, 2023
@ohaibbq
Copy link
Contributor

ohaibbq commented Jan 26, 2024

Hi @Kulkarnionkar2007. I accidentally made a duplicate of this issue at #262 and have implemented a fix at #263.

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
Development

Successfully merging a pull request may close this issue.

3 participants