mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
Sample test data (#10487)
Co-authored-by: bogdan kyryliuk <bogdankyryliuk@dropbox.com>
This commit is contained in:
@@ -52,9 +52,10 @@ def gen_filter(
|
||||
}
|
||||
|
||||
|
||||
def load_data(tbl_name: str, database: Database) -> None:
|
||||
def load_data(tbl_name: str, database: Database, sample: bool = False) -> None:
|
||||
pdf = pd.read_json(get_example_data("birth_names.json.gz"))
|
||||
pdf.ds = pd.to_datetime(pdf.ds, unit="ms")
|
||||
pdf = pdf.head(100) if sample else pdf
|
||||
pdf.to_sql(
|
||||
tbl_name,
|
||||
database.get_sqla_engine(),
|
||||
@@ -72,7 +73,9 @@ def load_data(tbl_name: str, database: Database) -> None:
|
||||
print("-" * 80)
|
||||
|
||||
|
||||
def load_birth_names(only_metadata: bool = False, force: bool = False) -> None:
|
||||
def load_birth_names(
|
||||
only_metadata: bool = False, force: bool = False, sample: bool = False
|
||||
) -> None:
|
||||
"""Loading birth name dataset from a zip file in the repo"""
|
||||
# pylint: disable=too-many-locals
|
||||
tbl_name = "birth_names"
|
||||
@@ -80,7 +83,7 @@ def load_birth_names(only_metadata: bool = False, force: bool = False) -> None:
|
||||
table_exists = database.has_table_by_name(tbl_name)
|
||||
|
||||
if not only_metadata and (not table_exists or force):
|
||||
load_data(tbl_name, database)
|
||||
load_data(tbl_name, database, sample=sample)
|
||||
|
||||
obj = db.session.query(TBL).filter_by(table_name=tbl_name).first()
|
||||
if not obj:
|
||||
|
||||
Reference in New Issue
Block a user