Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Add deletion vectors generated table #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions dat/generated_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Callable, List, Tuple

import pyspark.sql
import pyspark.sql.functions as F
import pyspark.sql.types as types
from delta.tables import DeltaTable
from pyspark.sql import SparkSession
Expand Down Expand Up @@ -403,3 +404,28 @@ def create_no_stats(case: TestCaseInfo, spark: SparkSession):
df = get_sample_data(spark, seed=i, nrows=5)
df.repartition(1).write.format('delta').mode(
'overwrite').save(case.delta_root)


@reference_table(
name='deletion_vectors',
description='Table with deletion vectors',
)
def create_deletion_vectors(case: TestCaseInfo, spark: SparkSession):
columns = ['letter', 'number', 'a_float']
data = [('a', 1, 1.1), ('b', 2, 2.2), ('c', 3, 3.3)]
df = spark.createDataFrame(data, schema=columns)

df.repartition(1).write.format('delta').save(case.delta_root)
save_expected(case)

delta_path = str(Path(case.delta_root).absolute())
delta_table = DeltaTable.create(spark).location(delta_path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think you need a .execute() here


spark.sql(
f"ALTER TABLE delta.`{delta_path}` SET TBLPROPERTIES ('delta.enableDeletionVectors' = true)"
)

delta_table.delete(F.col("letter") == "a")

delta_table.toDF().repartition(1).write.format('delta').mode('append').save(case.delta_root)
save_expected(case)
Loading
Loading