From 2e9b4155b78407b7818e5b1e4f86516ac4a762e0 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Wed, 23 Aug 2023 13:38:20 -0400 Subject: [PATCH 1/2] revert update agate for int --- core/dbt/clients/agate_helper.py | 12 ------------ tests/functional/show/fixtures.py | 8 -------- tests/functional/show/test_show.py | 17 ----------------- tests/unit/test_agate_helper.py | 20 ++++++++++---------- 4 files changed, 10 insertions(+), 47 deletions(-) diff --git a/core/dbt/clients/agate_helper.py b/core/dbt/clients/agate_helper.py index 273d9c51923..642ade4e619 100644 --- a/core/dbt/clients/agate_helper.py +++ b/core/dbt/clients/agate_helper.py @@ -12,17 +12,6 @@ BOM = BOM_UTF8.decode("utf-8") # '\ufeff' -class Integer(agate.data_types.DataType): - def cast(self, d): - if type(d) == int: - return d - else: - raise agate.exceptions.CastError('Can not parse value "%s" as Integer.' % d) - - def jsonify(self, d): - return d - - class Number(agate.data_types.Number): # undo the change in https://github.com/wireservice/agate/pull/733 # i.e. do not cast True and False to numeric 1 and 0 @@ -58,7 +47,6 @@ def build_type_tester( ) -> agate.TypeTester: types = [ - Integer(null_values=("null", "")), Number(null_values=("null", "")), agate.data_types.Date(null_values=("null", ""), date_format="%Y-%m-%d"), agate.data_types.DateTime(null_values=("null", ""), datetime_format="%Y-%m-%d %H:%M:%S"), diff --git a/tests/functional/show/fixtures.py b/tests/functional/show/fixtures.py index 578c6b5f096..85bfcd26c29 100644 --- a/tests/functional/show/fixtures.py +++ b/tests/functional/show/fixtures.py @@ -2,14 +2,6 @@ select * from {{ ref('sample_seed') }} """ -models__sample_number_model = """ -select - cast(1.0 as int) as float_to_int_field, - 3.0 as float_field, - 4.3 as float_with_dec_field, - 5 as int_field -""" - models__second_model = """ select sample_num as col_one, diff --git a/tests/functional/show/test_show.py b/tests/functional/show/test_show.py index 4420d02a551..13e31f74543 100644 --- a/tests/functional/show/test_show.py +++ b/tests/functional/show/test_show.py @@ -6,7 +6,6 @@ models__second_ephemeral_model, seeds__sample_seed, models__sample_model, - models__sample_number_model, models__second_model, models__ephemeral_model, schema_yml, @@ -20,7 +19,6 @@ class BaseTestShow: def models(self): return { "sample_model.sql": models__sample_model, - "sample_number_model.sql": models__sample_number_model, "second_model.sql": models__second_model, "ephemeral_model.sql": models__ephemeral_model, "sql_header.sql": models__sql_header, @@ -73,21 +71,6 @@ def test_select_single_model_json(self, project): assert "sample_bool" in log_output -class TestSelectNumerics(BaseTestShow): - def test_numeric_values(self, project): - run_dbt(["build"]) - (results, log_output) = run_dbt_and_capture( - ["show", "--select", "sample_number_model", "--output", "json"] - ) - assert "Previewing node 'sample_number_model'" not in log_output - assert "1.0" not in log_output - assert "1" in log_output - assert "3.0" in log_output - assert "4.3" in log_output - assert "5" in log_output - assert "5.0" not in log_output - - class TestInlinePass(BaseTestShow): def test_inline_pass(self, project): run_dbt(["build"]) diff --git a/tests/unit/test_agate_helper.py b/tests/unit/test_agate_helper.py index 87658633158..a2d9fcdb0e2 100644 --- a/tests/unit/test_agate_helper.py +++ b/tests/unit/test_agate_helper.py @@ -121,37 +121,37 @@ def test_datetime_formats(self): self.assertEqual(tbl[0][0], expected) def test_merge_allnull(self): - t1 = agate_helper.table_from_rows([(1, "a", None), (2, "b", None)], ("a", "b", "c")) - t2 = agate_helper.table_from_rows([(3, "c", None), (4, "d", None)], ("a", "b", "c")) + t1 = agate.Table([(1, "a", None), (2, "b", None)], ("a", "b", "c")) + t2 = agate.Table([(3, "c", None), (4, "d", None)], ("a", "b", "c")) result = agate_helper.merge_tables([t1, t2]) self.assertEqual(result.column_names, ("a", "b", "c")) - assert isinstance(result.column_types[0], agate_helper.Integer) + assert isinstance(result.column_types[0], agate.data_types.Number) assert isinstance(result.column_types[1], agate.data_types.Text) assert isinstance(result.column_types[2], agate.data_types.Number) self.assertEqual(len(result), 4) def test_merge_mixed(self): - t1 = agate_helper.table_from_rows([(1, "a", None), (2, "b", None)], ("a", "b", "c")) - t2 = agate_helper.table_from_rows([(3, "c", "dog"), (4, "d", "cat")], ("a", "b", "c")) - t3 = agate_helper.table_from_rows([(3, "c", None), (4, "d", None)], ("a", "b", "c")) + t1 = agate.Table([(1, "a", None), (2, "b", None)], ("a", "b", "c")) + t2 = agate.Table([(3, "c", "dog"), (4, "d", "cat")], ("a", "b", "c")) + t3 = agate.Table([(3, "c", None), (4, "d", None)], ("a", "b", "c")) result = agate_helper.merge_tables([t1, t2]) self.assertEqual(result.column_names, ("a", "b", "c")) - assert isinstance(result.column_types[0], agate_helper.Integer) + assert isinstance(result.column_types[0], agate.data_types.Number) assert isinstance(result.column_types[1], agate.data_types.Text) assert isinstance(result.column_types[2], agate.data_types.Text) self.assertEqual(len(result), 4) result = agate_helper.merge_tables([t2, t3]) self.assertEqual(result.column_names, ("a", "b", "c")) - assert isinstance(result.column_types[0], agate_helper.Integer) + assert isinstance(result.column_types[0], agate.data_types.Number) assert isinstance(result.column_types[1], agate.data_types.Text) assert isinstance(result.column_types[2], agate.data_types.Text) self.assertEqual(len(result), 4) result = agate_helper.merge_tables([t1, t2, t3]) self.assertEqual(result.column_names, ("a", "b", "c")) - assert isinstance(result.column_types[0], agate_helper.Integer) + assert isinstance(result.column_types[0], agate.data_types.Number) assert isinstance(result.column_types[1], agate.data_types.Text) assert isinstance(result.column_types[2], agate.data_types.Text) self.assertEqual(len(result), 6) @@ -191,7 +191,7 @@ def test_nocast_bool_01(self): self.assertEqual(len(tbl), len(result_set)) assert isinstance(tbl.column_types[0], agate.data_types.Boolean) - assert isinstance(tbl.column_types[1], agate_helper.Integer) + assert isinstance(tbl.column_types[1], agate.data_types.Number) expected = [ [True, Decimal(1)], From 1515fa32a07f96b6a94df43db74c3f20e6e6fc0b Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Wed, 23 Aug 2023 13:39:07 -0400 Subject: [PATCH 2/2] remove changelog --- .changes/unreleased/Fixes-20230803-093502.yaml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .changes/unreleased/Fixes-20230803-093502.yaml diff --git a/.changes/unreleased/Fixes-20230803-093502.yaml b/.changes/unreleased/Fixes-20230803-093502.yaml deleted file mode 100644 index ffa0b3aba1c..00000000000 --- a/.changes/unreleased/Fixes-20230803-093502.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixes -body: Add explicit support for integers for the show command -time: 2023-08-03T09:35:02.163968-05:00 -custom: - Author: dave-connors-3 - Issue: "8153"