Skip to content

Conversation

arwas11
Copy link

@arwas11 arwas11 commented Jan 17, 2025

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #384564457 🦕

@arwas11 arwas11 requested review from tswast and sycai January 17, 2025 18:35
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery-magics API. labels Jan 17, 2025
bpd.options.bigquery.credentials = context.credentials
raise ValueError(
"Please install the 'bigframes' package (pip install bigframes) to use the bigframes engine."
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this intact for now.

Suggested change
)
)
bpd.options.bigquery.project = context.project
bpd.options.bigquery.credentials = context.credentials

At some point we will want to refactor this logic to use the new magics_settings, but not in this PR.

# This missing reason is for options that are magics-only and apply to all
# engines. For example, the destination variable is a magics-only setting
# and doesn't affect how queries are handled by the engine.
ENGINE_UNIVERSAL = enum.auto()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our discussion offline about the spreadsheet, let's add an additional option for SUPPORTED_BY_ENGINE_BUT_NO_OPTION for things where there's some support for it in the engine (e.g. by setting the cell_arg), but there's no global option to override it.

Suggested change
ENGINE_UNIVERSAL = enum.auto()
ENGINE_UNIVERSAL = enum.auto()
# Similar to ENGINE_UNIVERSAL, these options _do_ work, but there
# isn't a way to globally override them. Use this instead of ENGINE_UNIVERSAL
# for things that really do require some explicit support in the engine (e.g. query parameters)
# but don't have a way to set them for all queries.
SUPPORTED_BY_ENGINE_BUT_NO_OPTION = enum.auto()

description="Limits the number of rows in the returned DataFrame.",
cell_arg="--max_results",
magics_context=MissingReason.NOT_SUPPORTED_BY_ENGINE_BUT_POSSIBLE,
bigframes_option="read_gbq_query.max_results"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUPPORTED_BY_ENGINE_BUT_NO_OPTION

Anything on read_gbq_query is not a global option and we shouldn't include it here or in our docs for the magic. That's just an implementation detail.

MagicsSetting(
description="Set it to a query to estimate costs.",
cell_arg="--dry_run",
magics_context=MissingReason.NOT_SUPPORTED_BY_ENGINE_BUT_POSSIBLE,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUPPORTED_BY_ENGINE_BUT_NO_OPTION

description="Set it to a query to estimate costs.",
cell_arg="--dry_run",
magics_context=MissingReason.NOT_SUPPORTED_BY_ENGINE_BUT_POSSIBLE,
bigframes_option="read_gbq_query"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOT_SUPPORTED_BY_ENGINE_BUT_POSSIBLE

This one we haven't implemented yet. (Or maybe we have via the configuration argument in read_gbq_query? If so, then it's SUPPORTED_BY_ENGINE_BUT_NO_OPTION)

MagicsSetting(
description="Set it to use instead of Standard SQL.",
cell_arg="--use_legacy_sql",
magics_context=MissingReason.NOT_SUPPORTED_BY_ENGINE_BUT_POSSIBLE,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will almost never have NOT_SUPPORTED_BY_ENGINE_BUT_POSSIBLE for magics_context because that was the first engine we created (pandas engine). It's the bigframes one that is missing features like this.

If there is something missing, SUPPORTED_BY_ENGINE_BUT_NO_OPTION is likely the reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-magics API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants