Skip to content

Commit

Permalink
test: rename column names for birth_names dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud committed Jan 8, 2021
1 parent fd15dff commit 28f1d0d
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('AdhocMetrics', () => {
});

it('Clear metric and set simple adhoc metric', () => {
const metric = 'sum(sum_girls)';
const metric = 'sum(num_girls)';
const metricName = 'Sum Girls';
cy.get('[data-test=metrics]')
.find('[data-test="remove-control-button"]')
Expand Down Expand Up @@ -94,15 +94,15 @@ describe('AdhocMetrics', () => {
xit('Switch from custom sql tabs to simple', () => {
cy.get('[data-test=metrics]').within(() => {
cy.get('.Select__dropdown-indicator').click();
cy.get('input[type=text]').type('sum_girls{enter}');
cy.get('input[type=text]').type('num_girls{enter}');
});
cy.get('[data-test=metrics]')
.find('[data-test="metric-option"]')
.should('have.length', 2);

cy.get('#metrics-edit-popover').within(() => {
cy.get('#adhoc-metric-edit-tabs-tab-SQL').click();
cy.get('.ace_identifier').contains('sum_girls');
cy.get('.ace_identifier').contains('num_girls');
cy.get('.ace_content').click();
cy.get('.ace_text-input').type('{selectall}{backspace}SUM(num)');
cy.get('#adhoc-metric-edit-tabs-tab-SIMPLE').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ describe('Visualization > Pivot Table', () => {
expressionType: 'SIMPLE',
column: {
id: 338,
column_name: 'sum_boys',
column_name: 'num_boys',
expression: '',
filterable: false,
groupby: false,
is_dttm: false,
type: 'BIGINT',
optionName: '_col_sum_boys',
optionName: '_col_num_boys',
},
aggregate: 'SUM',
hasCustomLabel: false,
label: 'SUM(sum_boys)',
label: 'SUM(num_boys)',
optionName: 'metric_gvpdjt0v2qf_6hkf56o012',
};

Expand Down Expand Up @@ -88,7 +88,7 @@ describe('Visualization > Pivot Table', () => {
metrics: ['sum__num', TEST_METRIC],
});
cy.get('.chart-container tr:eq(0) th:eq(1)').contains('sum__num');
cy.get('.chart-container tr:eq(0) th:eq(2)').contains('SUM(sum_boys)');
cy.get('.chart-container tr:eq(0) th:eq(2)').contains('SUM(num_boys)');
cy.get('.chart-container tr:eq(1) th:eq(0)').contains('state');
cy.get('.chart-container tr:eq(2) th:eq(0)').contains('name');
});
Expand All @@ -100,7 +100,7 @@ describe('Visualization > Pivot Table', () => {
metrics: ['sum__num', TEST_METRIC],
});
cy.get('.chart-container tr:eq(0) th:eq(2)').contains('sum__num');
cy.get('.chart-container tr:eq(0) th:eq(3)').contains('SUM(sum_boys)');
cy.get('.chart-container tr:eq(0) th:eq(3)').contains('SUM(num_boys)');
cy.get('.chart-container tr:eq(2) th:eq(0)').contains('name');
cy.get('.chart-container tr:eq(2) th:eq(1)').contains('gender');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Visualization > Table', () => {

const PERCENT_METRIC = {
expressionType: 'SQL',
sqlExpression: 'CAST(SUM(sum_girls)+AS+FLOAT)/SUM(num)',
sqlExpression: 'CAST(SUM(num_girls)+AS+FLOAT)/SUM(num)',
column: null,
aggregate: null,
hasCustomLabel: true,
Expand Down
48 changes: 24 additions & 24 deletions superset-frontend/spec/fixtures/mockDatasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ export default {
verbose_map: {
count: 'COUNT(*)',
__timestamp: 'Time',
sum__sum_girls: 'sum__sum_girls',
sum__num_girls: 'sum__num_girls',
name: 'name',
avg__sum_girls: 'avg__sum_girls',
avg__num_girls: 'avg__num_girls',
gender: 'gender',
sum_girls: 'sum_girls',
num_girls: 'num_girls',
ds: 'ds',
sum__sum_boys: 'sum__sum_boys',
sum__num_boys: 'sum__num_boys',
state: 'state',
num: 'num',
sum__num: 'sum__num',
sum_boys: 'sum_boys',
num_boys: 'num_boys',
avg__num: 'avg__num',
avg__sum_boys: 'avg__sum_boys',
avg__num_boys: 'avg__num_boys',
},
metrics: [
{
Expand All @@ -54,31 +54,31 @@ export default {
description: null,
},
{
expression: 'SUM(birth_names.sum_boys)',
expression: 'SUM(birth_names.num_boys)',
warning_text: null,
verbose_name: 'sum__sum_boys',
metric_name: 'sum__sum_boys',
verbose_name: 'sum__num_boys',
metric_name: 'sum__num_boys',
description: null,
},
{
expression: 'AVG(birth_names.sum_boys)',
expression: 'AVG(birth_names.num_boys)',
warning_text: null,
verbose_name: 'avg__sum_boys',
metric_name: 'avg__sum_boys',
verbose_name: 'avg__num_boys',
metric_name: 'avg__num_boys',
description: null,
},
{
expression: 'SUM(birth_names.sum_girls)',
expression: 'SUM(birth_names.num_girls)',
warning_text: null,
verbose_name: 'sum__sum_girls',
metric_name: 'sum__sum_girls',
verbose_name: 'sum__num_girls',
metric_name: 'sum__num_girls',
description: null,
},
{
expression: 'AVG(birth_names.sum_girls)',
expression: 'AVG(birth_names.num_girls)',
warning_text: null,
verbose_name: 'avg__sum_girls',
metric_name: 'avg__sum_girls',
verbose_name: 'avg__num_girls',
metric_name: 'avg__num_girls',
description: null,
},
{
Expand Down Expand Up @@ -149,7 +149,7 @@ export default {
is_dttm: false,
expression: '',
groupby: false,
column_name: 'sum_boys',
column_name: 'num_boys',
},
{
type: 'BIGINT',
Expand All @@ -159,7 +159,7 @@ export default {
is_dttm: false,
expression: '',
groupby: false,
column_name: 'sum_girls',
column_name: 'num_girls',
},
],
id,
Expand Down Expand Up @@ -189,10 +189,10 @@ export default {
['["num", false]', 'num [desc]'],
['["state", true]', 'state [asc]'],
['["state", false]', 'state [desc]'],
['["sum_boys", true]', 'sum_boys [asc]'],
['["sum_boys", false]', 'sum_boys [desc]'],
['["sum_girls", true]', 'sum_girls [asc]'],
['["sum_girls", false]', 'sum_girls [desc]'],
['["num_boys", true]', 'num_boys [asc]'],
['["num_boys", false]', 'num_boys [desc]'],
['["num_girls", true]', 'num_girls [asc]'],
['["num_girls", false]', 'num_girls [desc]'],
],
type: 'table',
edit_url: '/tablemodelview/edit/7',
Expand Down
6 changes: 3 additions & 3 deletions superset/examples/birth_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def gen_filter(


def load_data(tbl_name: str, database: Database, sample: bool = False) -> None:
pdf = pd.read_json(get_example_data("birth_names.json.gz"))
pdf = pd.read_json(get_example_data("birth_names2.json.gz"))
# TODO(bkyryliuk): move load examples data into the pytest fixture
if database.backend == "presto":
pdf.ds = pd.to_datetime(pdf.ds, unit="ms")
Expand Down Expand Up @@ -221,14 +221,14 @@ def create_slices(tbl: BaseDatasource) -> Tuple[List[Slice], List[Slice]]:
metrics=[
{
"expressionType": "SIMPLE",
"column": {"column_name": "sum_boys", "type": "BIGINT(20)"},
"column": {"column_name": "num_boys", "type": "BIGINT(20)"},
"aggregate": "SUM",
"label": "Boys",
"optionName": "metric_11",
},
{
"expressionType": "SIMPLE",
"column": {"column_name": "sum_girls", "type": "BIGINT(20)"},
"column": {"column_name": "num_girls", "type": "BIGINT(20)"},
"aggregate": "SUM",
"label": "Girls",
"optionName": "metric_12",
Expand Down
6 changes: 3 additions & 3 deletions tests/databases/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_export_database_command(self, mock_g):
"metric_name": "ratio",
"verbose_name": "Ratio Boys/Girls",
"metric_type": None,
"expression": "sum(sum_boys) / sum(sum_girls)",
"expression": "sum(num_boys) / sum(num_girls)",
"description": "This represents the ratio of boys/girls",
"d3format": ".2%",
"extra": None,
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_export_database_command(self, mock_g):
"python_date_format": None,
},
{
"column_name": "sum_girls",
"column_name": "num_girls",
"verbose_name": None,
"is_dttm": False,
"is_active": None,
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_export_database_command(self, mock_g):
"python_date_format": None,
},
{
"column_name": "sum_boys",
"column_name": "num_boys",
"verbose_name": None,
"is_dttm": None,
"is_active": None,
Expand Down
8 changes: 4 additions & 4 deletions tests/datasets/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ def test_import_v0_dataset_cli_export(self):
"state",
"gender",
"name",
"sum_boys",
"sum_girls",
"num_boys",
"num_girls",
"num",
]

Expand Down Expand Up @@ -276,8 +276,8 @@ def test_import_v0_dataset_ui_export(self):
"state",
"gender",
"name",
"sum_boys",
"sum_girls",
"num_boys",
"num_girls",
"num",
}

Expand Down
6 changes: 3 additions & 3 deletions tests/datasource_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_external_metadata_for_physical_table(self):
resp = self.get_json_resp(url)
col_names = {o.get("name") for o in resp}
self.assertEqual(
col_names, {"sum_boys", "num", "gender", "name", "ds", "state", "sum_girls"}
col_names, {"num_boys", "num", "gender", "name", "ds", "state", "num_girls"}
)

def test_external_metadata_for_virtual_table(self):
Expand Down Expand Up @@ -179,13 +179,13 @@ def test_get_datasource(self):
self.assertEqual(
col_names,
{
"sum_boys",
"num_boys",
"num",
"gender",
"name",
"ds",
"state",
"sum_girls",
"num_girls",
"num_california",
},
)
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
{
"id": 509,
"column_name": "sum_boys",
"column_name": "num_boys",
"verbose_name": None,
"description": None,
"expression": None,
Expand All @@ -88,7 +88,7 @@
},
{
"id": 510,
"column_name": "sum_girls",
"column_name": "num_girls",
"verbose_name": None,
"description": None,
"expression": "",
Expand Down Expand Up @@ -144,7 +144,7 @@
"metric_name": "ratio",
"verbose_name": "Ratio Boys/Girls",
"description": "This represents the ratio of boys/girls",
"expression": "sum(sum_boys) / sum(sum_girls)",
"expression": "sum(num_boys) / sum(num_girls)",
"warning_text": "no warning",
"d3format": ".2%",
},
Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
{"column_name": "state", "type": "VARCHAR(10)"},
{"column_name": "gender", "type": "VARCHAR(16)"},
{"column_name": "name", "type": "VARCHAR(255)"},
{"column_name": "sum_boys", "type": "BIGINT"},
{"column_name": "sum_girls", "type": "BIGINT"},
{"column_name": "num_boys", "type": "BIGINT"},
{"column_name": "num_girls", "type": "BIGINT"},
{"column_name": "num", "type": "BIGINT"},
],
"filter_select_enabled": True,
Expand Down Expand Up @@ -201,7 +201,7 @@
"__TableColumn__": {
"changed_by_fk": None,
"changed_on": {"__datetime__": "2020-10-07T15:50:00"},
"column_name": "sum_boys",
"column_name": "num_boys",
"created_by_fk": None,
"created_on": {"__datetime__": "2020-10-07T15:50:00"},
"description": None,
Expand All @@ -222,7 +222,7 @@
"__TableColumn__": {
"changed_by_fk": None,
"changed_on": {"__datetime__": "2020-10-07T15:50:00"},
"column_name": "sum_girls",
"column_name": "num_girls",
"created_by_fk": None,
"created_on": {"__datetime__": "2020-10-07T15:50:00"},
"description": None,
Expand Down
2 changes: 1 addition & 1 deletion tests/model_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def query_with_expr_helper(self, is_timeseries, inner_join=True):
spec.allows_joins = inner_join
arbitrary_gby = "state || gender || '_test'"
arbitrary_metric = dict(
label="arbitrary", expressionType="SQL", sqlExpression="SUM(sum_boys)"
label="arbitrary", expressionType="SQL", sqlExpression="SUM(num_boys)"
)
query_obj = dict(
groupby=[arbitrary_gby, "name"],
Expand Down

0 comments on commit 28f1d0d

Please sign in to comment.