Ejemplo n.º 1
0
    def add_new_column():
        test_schema["properties"]["third"] = {"type": "string"}
        with test_schema_path.open("w") as fp:
            json.dump(test_schema, fp)

        run(f"git add {test_schema_path}")
        run(["git", "commit", "-m", "Add a new column"])
        return checkout_transpile_schemas(tmp_git / "schemas", "HEAD",
                                          "HEAD~1", tmp_path / "integration")
Ejemplo n.º 2
0
    def add_test_schema() -> Tuple[Path, Path]:
        test_schema_path.parent.mkdir(parents=True, exist_ok=False)
        with test_schema_path.open("w") as fp:
            json.dump(test_schema, fp)

        run(f"git add {test_schema_path}")
        run(["git", "commit", "-m", "Add a test schema"])
        return checkout_transpile_schemas(tmp_git / "schemas", "HEAD",
                                          "HEAD~1", tmp_path / "integration")
Ejemplo n.º 3
0
def diff(base_ref, head_ref, input_directory, output_directory):
    # check that the correct tools are installed
    run("diff --version")
    run("git --version")
    run("jsonschema-transpiler --version")

    schemas_path = Path(input_directory)
    integration_path = Path(output_directory)

    head_rev_path, base_rev_path = checkout_transpile_schemas(
        schemas_path, head_ref, base_ref, integration_path)

    write_schema_diff(head_rev_path, base_rev_path, integration_path)
Ejemplo n.º 4
0
def diff(base_ref, head_ref, input_directory, output_directory):
    # check that the correct tools are installed
    run("diff --version")
    run("git --version")
    run("jsonschema-transpiler --version")

    schemas_path = Path(input_directory)
    integration_path = Path(output_directory)

    head_rev_path, base_rev_path = checkout_transpile_schemas(
        schemas_path, head_ref, base_ref, integration_path
    )

    # also compute the columns for each of these
    def write_compact(path: Path):
        for p in path.glob("*.bq"):
            out = p.parent / p.name.replace(".bq", ".txt")
            bq_schema = json.loads(p.read_text())
            out.write_text("\n".join(compute_compact_columns(bq_schema)))

    write_compact(head_rev_path)
    write_compact(base_rev_path)

    write_schema_diff(
        head_rev_path,
        base_rev_path,
        integration_path,
        prefix="bq_schema",
        options="--new-file --exclude *.txt",
    )

    write_schema_diff(
        head_rev_path,
        base_rev_path,
        integration_path,
        prefix="compact_schema",
        options="--new-file --exclude *.bq",
    )