Skip to content

Use native parameter approach by default#277

Merged
susodapop merged 27 commits intonative-query-params-stagingfrom
use-native-by-default
Nov 10, 2023
Merged

Use native parameter approach by default#277
susodapop merged 27 commits intonative-query-params-stagingfrom
use-native-by-default

Conversation

@susodapop
Copy link
Contributor

@susodapop susodapop commented Nov 10, 2023

Description

This PR updates the connector so that the native parameter approach is enabled by default. It modifies the semantics of use_inline_params so that it now accepts three values:

  • False (default) Native parameter approach will be used.
  • True: Inline parameter approach will be used, and a warning will be issued
  • "silent": Inline parameter approach will be used, and no warning will be logged.

It also moves the warning message from the execute() method (where a warning would be logged on every "offending" query execution) and into the client construtor. This way the warning is logged once. We'd like to be kind to our friends that examine their logs 😉

Jesse Whitehouse added 21 commits November 9, 2023 12:45
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>

squash with two commits back

Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
This commit updates the test fixtures so that we automatically run the
NATIVE tests with both paramstyles.

For parameter features that are new in version 3.0.0 (DbsqlParameter)
we don't run with both parameter styles because there is no need for
syntax backwards-compatibility when using the new DbsqlParameter class.

i.e. Nobody should ever use DbsqlParameter with a ParamStyle.PYFORMAT
query

Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
We no longer need a separate 2 tests for doubles, as they are handled
in the new _eq() function.

Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
…ormer

Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
- Tests that use DbsqlParam will not run under both paramstyles
If a user is writing code with DbsqlParam then they *must* use the named
param style

- Likewise, if parameters are passed as a sequence then transform_paramstyle
will not be called.

- Adds tests for the inline ordinal parameter approach

Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
transform_paramstyle now needs a dictionary of parameters since it doesn't
use regex anymore

Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
… not

recognised by DBR.

Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Without this change, these tests would use the default approach which is
now native mode.

Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
"silent": Use inline parameters and don't log a warning
"""

if user_value is None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

declare as Option and set default in parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Jesse Whitehouse added 2 commits November 10, 2023 17:34
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Jesse Whitehouse added 2 commits November 10, 2023 17:38
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
@susodapop susodapop marked this pull request as ready for review November 10, 2023 22:45
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
@susodapop susodapop merged commit 9923c74 into native-query-params-staging Nov 10, 2023
@susodapop susodapop deleted the use-native-by-default branch November 10, 2023 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants