[
https://issues.apache.org/jira/browse/AIRFLOW-3222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16653570#comment-16653570
]
ASF GitHub Bot commented on AIRFLOW-3222:
-----------------------------------------
kaxil closed pull request #4060: [AIRFLOW-3222] Remove bql keyword from
BigQueryOperator
URL: https://github.com/apache/incubator-airflow/pull/4060
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/contrib/hooks/bigquery_hook.py
b/airflow/contrib/hooks/bigquery_hook.py
index dba4618e35..744cd673e9 100644
--- a/airflow/contrib/hooks/bigquery_hook.py
+++ b/airflow/contrib/hooks/bigquery_hook.py
@@ -480,7 +480,6 @@ def create_external_table(self,
)
def run_query(self,
- bql=None,
sql=None,
destination_dataset_table=None,
write_disposition='WRITE_EMPTY',
@@ -506,9 +505,6 @@ def run_query(self,
For more details about these parameters.
- :param bql: (Deprecated. Use `sql` parameter instead) The BigQuery SQL
- to execute.
- :type bql: str
:param sql: The BigQuery SQL to execute.
:type sql: str
:param destination_dataset_table: The dotted <dataset>.<table>
@@ -583,19 +579,6 @@ def run_query(self,
_validate_value("api_resource_configs['query']",
configuration['query'], dict)
- sql = bql if sql is None else sql
-
- # TODO remove `bql` in Airflow 2.0 - Jira: [AIRFLOW-2513]
- if bql:
- import warnings
- warnings.warn('Deprecated parameter `bql` used in '
- '`BigQueryBaseCursor.run_query` '
- 'Use `sql` parameter instead to pass the sql to be '
- 'executed. `bql` parameter is deprecated and '
- 'will be removed in a future version of '
- 'Airflow.',
- category=DeprecationWarning)
-
if sql is None and not configuration['query'].get('query', None):
raise TypeError('`BigQueryBaseCursor.run_query` '
'missing 1 required positional argument: `sql`')
diff --git a/airflow/contrib/operators/bigquery_operator.py
b/airflow/contrib/operators/bigquery_operator.py
index 9386e57c07..06fc516bd5 100644
--- a/airflow/contrib/operators/bigquery_operator.py
+++ b/airflow/contrib/operators/bigquery_operator.py
@@ -29,11 +29,6 @@ class BigQueryOperator(BaseOperator):
"""
Executes BigQuery SQL queries in a specific BigQuery database
- :param bql: (Deprecated. Use `sql` parameter instead) the sql code to be
- executed (templated)
- :type bql: Can receive a str representing a sql statement,
- a list of str (sql statements), or reference to a template file.
- Template reference are recognized by str ending in '.sql'.
:param sql: the sql code to be executed (templated)
:type sql: Can receive a str representing a sql statement,
a list of str (sql statements), or reference to a template file.
@@ -104,13 +99,12 @@ class BigQueryOperator(BaseOperator):
:type cluster_fields: list of str
"""
- template_fields = ('bql', 'sql', 'destination_dataset_table', 'labels')
+ template_fields = ('sql', 'destination_dataset_table', 'labels')
template_ext = ('.sql', )
ui_color = '#e4f0e8'
@apply_defaults
def __init__(self,
- bql=None,
sql=None,
destination_dataset_table=False,
write_disposition='WRITE_EMPTY',
@@ -133,8 +127,7 @@ def __init__(self,
*args,
**kwargs):
super(BigQueryOperator, self).__init__(*args, **kwargs)
- self.bql = bql
- self.sql = sql if sql else bql
+ self.sql = sql
self.destination_dataset_table = destination_dataset_table
self.write_disposition = write_disposition
self.create_disposition = create_disposition
@@ -157,16 +150,6 @@ def __init__(self,
self.api_resource_configs = {}
self.cluster_fields = cluster_fields
- # TODO remove `bql` in Airflow 2.0
- if self.bql:
- import warnings
- warnings.warn('Deprecated parameter `bql` used in Task id: {}. '
- 'Use `sql` parameter instead to pass the sql to be '
- 'executed. `bql` parameter is deprecated and '
- 'will be removed in a future version of '
- 'Airflow.'.format(self.task_id),
- category=DeprecationWarning)
-
if self.sql is None:
raise TypeError('{} missing 1 required positional '
'argument: `sql`'.format(self.task_id))
diff --git a/tests/contrib/hooks/test_bigquery_hook.py
b/tests/contrib/hooks/test_bigquery_hook.py
index 77a31f0320..a6062369ac 100644
--- a/tests/contrib/hooks/test_bigquery_hook.py
+++ b/tests/contrib/hooks/test_bigquery_hook.py
@@ -19,7 +19,6 @@
#
import unittest
-import warnings
from google.auth.exceptions import GoogleAuthError
import mock
@@ -207,16 +206,6 @@ def mock_job_cancel(projectId, jobId):
class TestBigQueryBaseCursor(unittest.TestCase):
- def test_bql_deprecation_warning(self):
- with warnings.catch_warnings(record=True) as w:
- hook.BigQueryBaseCursor("test", "test").run_query(
- bql='select * from test_table'
- )
- yield
- self.assertIn(
- 'Deprecated parameter `bql`',
- w[0].message.args[0])
-
def test_invalid_schema_update_options(self):
with self.assertRaises(Exception) as context:
hook.BigQueryBaseCursor("test", "test").run_load(
@@ -227,16 +216,6 @@ def test_invalid_schema_update_options(self):
)
self.assertIn("THIS IS NOT VALID", str(context.exception))
- def test_nobql_nosql_param_error(self):
- with self.assertRaises(TypeError) as context:
- hook.BigQueryBaseCursor("test", "test").run_query(
- sql=None,
- bql=None
- )
- self.assertIn(
- 'missing 1 required positional',
- str(context.exception))
-
def test_invalid_schema_update_and_write_disposition(self):
with self.assertRaises(Exception) as context:
hook.BigQueryBaseCursor("test", "test").run_load(
diff --git a/tests/contrib/operators/test_bigquery_operator.py
b/tests/contrib/operators/test_bigquery_operator.py
index 9ce3b478d3..4e62221395 100644
--- a/tests/contrib/operators/test_bigquery_operator.py
+++ b/tests/contrib/operators/test_bigquery_operator.py
@@ -18,11 +18,9 @@
# under the License.
import unittest
-import warnings
from airflow.contrib.operators.bigquery_operator import \
- BigQueryCreateExternalTableOperator, \
- BigQueryOperator, BigQueryCreateEmptyTableOperator, \
+ BigQueryCreateExternalTableOperator, BigQueryCreateEmptyTableOperator, \
BigQueryDeleteDatasetOperator, BigQueryCreateEmptyDatasetOperator
try:
@@ -42,18 +40,6 @@
TEST_SOURCE_FORMAT = 'CSV'
-class BigQueryOperatorTest(unittest.TestCase):
- def test_bql_deprecation_warning(self):
- with warnings.catch_warnings(record=True) as w:
- BigQueryOperator(
- task_id='test_deprecation_warning_for_bql',
- bql='select * from test_table'
- )
- self.assertIn(
- 'Deprecated parameter `bql`',
- w[0].message.args[0])
-
-
class BigQueryCreateEmptyTableOperatorTest(unittest.TestCase):
@mock.patch('airflow.contrib.operators.bigquery_operator.BigQueryHook')
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Remove bql keyword from BigQueryOperator
> ----------------------------------------
>
> Key: AIRFLOW-3222
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3222
> Project: Apache Airflow
> Issue Type: Improvement
> Reporter: Fokko Driesprong
> Priority: Major
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)