Skip to content

Commit

Permalink
refactor: range use python generator
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka committed Nov 18, 2024
1 parent bb506a4 commit ec40b9a
Show file tree
Hide file tree
Showing 21 changed files with 395 additions and 417 deletions.
124 changes: 10 additions & 114 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ python = [
"common-system-info/python",
"daft-catalog/python",
"daft-catalog-python-catalog/python",
"daft-connect/python",
"daft-core/python",
"daft-csv/python",
"daft-dsl/python",
Expand Down Expand Up @@ -207,6 +206,7 @@ daft-local-plan = {path = "src/daft-local-plan"}
daft-logical-plan = {path = "src/daft-logical-plan"}
daft-micropartition = {path = "src/daft-micropartition"}
daft-physical-plan = {path = "src/daft-physical-plan"}
daft-scan = {path = "src/daft-scan"}
daft-schema = {path = "src/daft-schema"}
daft-sql = {path = "src/daft-sql"}
daft-table = {path = "src/daft-table"}
Expand Down
29 changes: 29 additions & 0 deletions daft/io/range.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Callable

if TYPE_CHECKING:
from collections.abc import Iterator

from daft import DataType
from daft.io._generator import GeneratorScanOperator
from daft.logical.schema import Schema
from daft.table.table import Table


def _range_generators(start: int, end: int, step: int) -> Iterator[Callable[[], Iterator[Table]]]:
def generator_for_value(value: int) -> Callable[[], Iterator[Table]]:
def generator() -> Iterator[Table]:
yield Table.from_pydict({"id": [value]})

return generator

for value in range(start, end, step):
yield generator_for_value(value)


class RangeScanOperator(GeneratorScanOperator):
def __init__(self, start: int, end: int, step: int = 1) -> None:
schema = Schema._from_field_name_and_types([("id", DataType.int64())])

super().__init__(schema=schema, generators=_range_generators(start, end, step))
26 changes: 14 additions & 12 deletions src/daft-connect/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
[dependencies]
arrow2 = {workspace = true}
common-daft-config = {workspace = true, features = ["python"]}
daft-core = {workspace = true, features = ["python"]}
daft-local-execution = {workspace = true, features = ["python"]}
daft-local-plan = {workspace = true, features = ["python"]}
daft-logical-plan = {workspace = true, features = ["python"]}
daft-micropartition = {workspace = true, features = ["python"]}
daft-scan = {workspace = true, features = ["python"]}
daft-schema = {workspace = true, features = ["python"]}
daft-table = {workspace = true, features = ["python"]}
dashmap = "6.1.0"
eyre = "0.6.12"
futures = "0.3.31"
pyo3 = {workspace = true, optional = true}
pyo3 = {workspace = true}
spark-connect = {workspace = true}
tokio = {version = "1.40.0", features = ["full"]}
tokio-util = {workspace = true}
tonic = "0.12.3"
tracing-subscriber = {version = "0.3.18", features = ["env-filter"]}
tracing-tracy = "0.11.3"
tracing = {workspace = true}
uuid = {version = "1.10.0", features = ["v4"]}
arrow2.workspace = true
daft-core.workspace = true
daft-schema.workspace = true
daft-table.workspace = true
spark-connect.workspace = true
tracing.workspace = true

[features]
python = ["dep:pyo3"]

[lints]
workspace = true
Expand Down
6 changes: 0 additions & 6 deletions src/daft-connect/src/convert.rs

This file was deleted.

61 changes: 0 additions & 61 deletions src/daft-connect/src/convert/data_conversion.rs

This file was deleted.

Loading

0 comments on commit ec40b9a

Please sign in to comment.