def test_auditdt_cm_diff(active_run, dolt_audit1, doltdb):
    doltdb = Dolt(doltdb)
    logs = list(doltdb.log(2).keys())

    with DoltDT(run=active_run, audit=dolt_audit1) as dolt:
        df = dolt.sql("SELECT * FROM `bar`", as_key="akey")
        diff = dolt.diff(from_commit=logs[1], to_commit=logs[0], table="bar")
Exemple #2
0
def dolt_audit1(doltdb):
    db = Dolt(doltdb)
    lg = db.log()
    commit = lg.popitem(last=False)[0]
    yield {
        "actions": {
            "bar": {
                "key": "bar",
                "config_id": "dd9f1f38-6802-4657-b869-602dde993180",
                "pathspec": "VersioningDemo/1611853111934656/start/1",
                "table_name": "bar",
                "kind": "read",
                "query": "SELECT * FROM `bar`",
                "commit": commit,
                "artifact_name": None,
                "timestamp": 1611853112.794624,
            }
        },
        "configs": {
            "dd9f1f38-6802-4657-b869-602dde993180": {
                "id": "dd9f1f38-6802-4657-b869-602dde993180",
                "database": doltdb,
                "branch": "master",
                "commit": commit,
                "dolthub_remote": False,
                "push_on_commit": False,
            }
        },
    }
Exemple #3
0
def test_detached_head_cm(doltdb):
    db = Dolt(doltdb)
    commits = list(db.log().keys())

    with detach_head(db, commits[1]):
        sum1 = db.sql("select sum(a) as sum from t1", result_format="csv")[0]

    with detach_head(db, commits[0]):
        sum2 = db.sql("select sum(a) as sum from t1", result_format="csv")[0]

    assert sum1["sum"] == "3"
    assert sum2["sum"] == "6"
def test_branchdt_diff(inactive_run, dolt_config, doltdb):
    doltdb = Dolt(doltdb)
    logs = list(doltdb.log(2).keys())

    dolt = DoltDT(config=dolt_config)
    diff = dolt.diff(from_commit=logs[1], to_commit=logs[0], table="bar")

    row = diff["bar"].iloc[0]
    assert row.from_A == 1
    assert row.from_B == 1
    assert row.to_A == 2
    assert row.to_B == 2
def test_custom_query_branch(active_run, dolt_config, doltdb):
    doltdb = Dolt(doltdb)
    logs = list(doltdb.log(2).keys())
    dolt_config.commit = logs[1]

    with DoltDT(run=active_run, config=dolt_config) as dolt:
        df = dolt.sql("SELECT * FROM `bar` LIMIT 2", as_key="akey")
    np.testing.assert_array_equal(df.A.values, [1, 1])
    audit = active_run.dolt
    assert "akey" in audit["actions"]
    assert audit["actions"]["akey"]["kind"] == "read"
    assert audit["actions"]["akey"]["query"] == "SELECT * FROM `bar` LIMIT 2"
Exemple #6
0
def _write_helper(dolt: Dolt, data: List[dict], update_type: str):
    write_rows(dolt, TEST_TABLE, data, update_type, ["id"], commit=True)
    commit_hash, _ = dolt.log().popitem(last=False)
    return dolt, commit_hash