本文整理匯總了Python中superset.connectors.sqla.models.SqlaTable類的典型用法代碼示例。如果您正苦於以下問題:Python SqlaTable類的具體用法?Python SqlaTable怎麽用?Python SqlaTable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了SqlaTable類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_import_table_override_sync
def test_import_table_override_sync(self):
table, dict_table = self.create_table(
'table_override', id=ID_PREFIX + 3,
cols_names=['col1'],
metric_names=['m1'])
imported_table = SqlaTable.import_from_dict(db.session, dict_table)
db.session.commit()
table_over, dict_table_over = self.create_table(
'table_override', id=ID_PREFIX + 3,
cols_names=['new_col1', 'col2', 'col3'],
metric_names=['new_metric1'])
imported_over_table = SqlaTable.import_from_dict(
session=db.session,
dict_rep=dict_table_over,
sync=['metrics', 'columns'])
db.session.commit()
imported_over = self.get_table(imported_over_table.id)
self.assertEquals(imported_table.id, imported_over.id)
expected_table, _ = self.create_table(
'table_override', id=ID_PREFIX + 3,
metric_names=['new_metric1'],
cols_names=['new_col1', 'col2', 'col3'])
self.assert_table_equals(expected_table, imported_over)
self.yaml_compare(
expected_table.export_to_dict(),
imported_over.export_to_dict())
示例2: test_import_table_override_idential
def test_import_table_override_idential(self):
table = self.create_table(
'copy_cat', id=10004, cols_names=['new_col1', 'col2', 'col3'],
metric_names=['new_metric1'])
imported_id = SqlaTable.import_obj(table, import_time=1993)
copy_table = self.create_table(
'copy_cat', id=10004, cols_names=['new_col1', 'col2', 'col3'],
metric_names=['new_metric1'])
imported_id_copy = SqlaTable.import_obj(
copy_table, import_time=1994)
self.assertEquals(imported_id, imported_id_copy)
self.assert_table_equals(copy_table, self.get_table(imported_id))
示例3: test_import_table_no_metadata
def test_import_table_no_metadata(self):
table, dict_table = self.create_table('pure_table', id=ID_PREFIX + 1)
new_table = SqlaTable.import_from_dict(db.session, dict_table)
db.session.commit()
imported_id = new_table.id
imported = self.get_table(imported_id)
self.assert_table_equals(table, imported)
self.yaml_compare(table.export_to_dict(), imported.export_to_dict())
示例4: test_import_table_2_col_2_met
def test_import_table_2_col_2_met(self):
table = self.create_table(
'table_2_col_2_met', id=10003, cols_names=['c1', 'c2'],
metric_names=['m1', 'm2'])
imported_id = SqlaTable.import_obj(table, import_time=1991)
imported = self.get_table(imported_id)
self.assert_table_equals(table, imported)
示例5: test_import_table_override_identical
def test_import_table_override_identical(self):
table, dict_table = self.create_table(
'copy_cat', id=ID_PREFIX + 4,
cols_names=['new_col1', 'col2', 'col3'],
metric_names=['new_metric1'])
imported_table = SqlaTable.import_from_dict(db.session, dict_table)
db.session.commit()
copy_table, dict_copy_table = self.create_table(
'copy_cat', id=ID_PREFIX + 4,
cols_names=['new_col1', 'col2', 'col3'],
metric_names=['new_metric1'])
imported_copy_table = SqlaTable.import_from_dict(db.session,
dict_copy_table)
db.session.commit()
self.assertEquals(imported_table.id, imported_copy_table.id)
self.assert_table_equals(copy_table, self.get_table(imported_table.id))
self.yaml_compare(imported_copy_table.export_to_dict(),
imported_table.export_to_dict())
示例6: test_import_table_2_col_2_met
def test_import_table_2_col_2_met(self):
table, dict_table = self.create_table(
'table_2_col_2_met', id=ID_PREFIX + 3, cols_names=['c1', 'c2'],
metric_names=['m1', 'm2'])
imported_table = SqlaTable.import_from_dict(db.session, dict_table)
db.session.commit()
imported = self.get_table(imported_table.id)
self.assert_table_equals(table, imported)
self.yaml_compare(table.export_to_dict(), imported.export_to_dict())
示例7: test_import_table_override
def test_import_table_override(self):
table = self.create_table(
'table_override', id=10003, cols_names=['col1'],
metric_names=['m1'])
imported_id = SqlaTable.import_obj(table, import_time=1991)
table_over = self.create_table(
'table_override', id=10003, cols_names=['new_col1', 'col2', 'col3'],
metric_names=['new_metric1'])
imported_over_id = SqlaTable.import_obj(
table_over, import_time=1992)
imported_over = self.get_table(imported_over_id)
self.assertEquals(imported_id, imported_over.id)
expected_table = self.create_table(
'table_override', id=10003, metric_names=['new_metric1', 'm1'],
cols_names=['col1', 'new_col1', 'col2', 'col3'])
self.assert_table_equals(expected_table, imported_over)
示例8: test_import_table_1_col_1_met
def test_import_table_1_col_1_met(self):
table = self.create_table(
'table_1_col_1_met', id=10002,
cols_names=["col1"], metric_names=["metric1"])
imported_id = SqlaTable.import_obj(table, import_time=1990)
imported = self.get_table(imported_id)
self.assert_table_equals(table, imported)
self.assertEquals(
{'remote_id': 10002, 'import_time': 1990, 'database_name': 'main'},
json.loads(imported.params))
示例9: test_import_table_1_col_1_met
def test_import_table_1_col_1_met(self):
table, dict_table = self.create_table(
'table_1_col_1_met', id=ID_PREFIX + 2,
cols_names=['col1'], metric_names=['metric1'])
imported_table = SqlaTable.import_from_dict(db.session, dict_table)
db.session.commit()
imported = self.get_table(imported_table.id)
self.assert_table_equals(table, imported)
self.assertEquals(
{DBREF: ID_PREFIX + 2, 'database_name': 'main'},
json.loads(imported.params))
self.yaml_compare(table.export_to_dict(), imported.export_to_dict())
示例10: test_comments_in_sqlatable_query
def test_comments_in_sqlatable_query(self):
clean_query = "SELECT '/* val 1 */' as c1, '-- val 2' as c2 FROM tbl"
commented_query = '/* comment 1 */' + clean_query + '-- comment 2'
table = SqlaTable(sql=commented_query)
rendered_query = text_type(table.get_from_clause())
self.assertEqual(clean_query, rendered_query)
示例11: test_import_table_no_metadata
def test_import_table_no_metadata(self):
table = self.create_table('pure_table', id=10001)
imported_id = SqlaTable.import_obj(table, import_time=1989)
imported = self.get_table(imported_id)
self.assert_table_equals(table, imported)