def test_dolt_table_to_python_value(mocker): mocker.patch("dolt_integrations.core.save", return_value=True) table = DoltTable(data=pandas.DataFrame(), config=DoltConfig(db_path="p")) lv = DoltTableNameTransformer.to_literal( self=None, ctx=None, python_val=table, python_type=DoltTable, expected=None, ) assert lv.scalar.generic["config"]["branch_conf"] is None
def test_dolt_table_read(db, dolt_config): @task def my_dolt(t: DoltTable) -> str: df = t.data return df.name.values[0] @workflow def my_wf(t: DoltTable) -> str: return my_dolt(t=t) dolt_config.tablename = "bar" x = my_wf(t=DoltTable(config=dolt_config)) assert x == "Dilly"
def generate_confs(a: int) -> typing.Tuple[DoltConfig, DoltConfig, DoltConfig]: users_conf = DoltConfig(db_path=doltdb_path, tablename="users", branch_conf=NewBranch(f"run/a_is_{a}")) query_users = DoltTable(config=DoltConfig( db_path=doltdb_path, sql="select * from users where `count` > 5", branch_conf=NewBranch(f"run/a_is_{a}"), ), ) big_users_conf = DoltConfig( db_path=doltdb_path, tablename="big_users", branch_conf=NewBranch(f"run/a_is_{a}"), ) return users_conf, query_users, big_users_conf
def my_dolt(a: int) -> DoltTable: df = pandas.DataFrame([("Alice", a)], columns=["name", "count"]) return DoltTable(data=df, config=dolt_config)
def filter_users(a: int, all_users: DoltTable, filtered_users: DoltTable, conf: DoltConfig) -> DoltTable: usernames = filtered_users.data[["name"]] return DoltTable(data=usernames, config=conf)
def populate_users(a: int, conf: DoltConfig) -> DoltTable: users = [("George", a), ("Alice", a * 2), ("Stephanie", a * 3)] df = pandas.DataFrame(users, columns=["name", "count"]) return DoltTable(data=df, config=conf)
def my_table(conf: DoltConfig) -> DoltTable: return DoltTable(config=conf)
def my_table() -> DoltTable: dolt_config.tablename = "bar" t = DoltTable(config=dolt_config) return t
def populate_rabbits(a: int) -> DoltTable: rabbits = [("George", a), ("Alice", a * 2), ("Sugar Maple", a * 3)] df = pd.DataFrame(rabbits, columns=["name", "count"]) return DoltTable(data=df, config=rabbits_conf)