예제 #1
0
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
예제 #2
0
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"
예제 #3
0
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
예제 #4
0
 def my_dolt(a: int) -> DoltTable:
     df = pandas.DataFrame([("Alice", a)], columns=["name", "count"])
     return DoltTable(data=df, config=dolt_config)
예제 #5
0
 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)
예제 #6
0
 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)
예제 #7
0
 def my_table(conf: DoltConfig) -> DoltTable:
     return DoltTable(config=conf)
예제 #8
0
 def my_table() -> DoltTable:
     dolt_config.tablename = "bar"
     t = DoltTable(config=dolt_config)
     return t
예제 #9
0
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)