Skip to content

Commit 7006b84

Browse files
committed
Revert "UNPICK uv install geodatafusion"
This reverts commit 692e399.
1 parent 89a9a40 commit 7006b84

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed
Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
1-
from datafusion import udaf
2-
from geodatafusion import native
1+
import pyarrow as pa
2+
from datafusion import udaf, SessionContext
3+
from datafusion.user_defined import Accumulator # base class for aggregators
34

4-
# replicate the original call
5-
udaf(native.Extent())
5+
# Define a simple test accumulator for demonstration:
6+
class TestAccumulator(Accumulator):
7+
def __init__(self) -> None:
8+
self.total = 0
9+
10+
def state(self) -> list[pa.Scalar]:
11+
return [pa.scalar(self.total)]
12+
13+
def update(self, *values: pa.Array) -> None:
14+
# Sum up integer values from the first argument
15+
self.total += sum(value.as_py() for value in values[0])
16+
17+
def merge(self, states: list[pa.Array]) -> None:
18+
# Assumes the state is a list with one scalar integer per actor
19+
self.total += sum(state[0].as_py() for state in states)
20+
21+
def evaluate(self) -> pa.Scalar:
22+
return pa.scalar(self.total)
23+
24+
# Create the test UDAF using TestAccumulator.
25+
# Note: the overload taking (accum, input_types, return_type, state_type, volatility, name)
26+
test_udaf = udaf(
27+
TestAccumulator, # accumulator function or type producing an Accumulator object
28+
[pa.int64()], # input types (list of one int64)
29+
pa.int64(), # return type
30+
[pa.int64()], # state type (list of one int64)
31+
"immutable", # volatility indicator
32+
name="test_udaf"
33+
)
34+
35+
# Register UDAF into a session context (if needed)
36+
ctx = SessionContext()
37+
ctx.register_udaf(test_udaf)
38+
39+
# The code should type check without error:
40+
print("Type checking passed for test_udaf!")

pyproject.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ classifiers = [
4343
"Programming Language :: Python",
4444
"Programming Language :: Rust",
4545
]
46-
dependencies = [
47-
"geodatafusion>=0.1.1",
48-
"pyarrow>=11.0.0",
49-
"typing-extensions;python_version<'3.13'",
50-
]
46+
dependencies = ["pyarrow>=11.0.0", "typing-extensions;python_version<'3.13'"]
5147
dynamic = ["version"]
5248

5349
[project.urls]

uv.lock

Lines changed: 1 addition & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)