Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b1175e4
[WIP] Poc.
sahnib Jan 22, 2024
0a98ed8
Introduce Protobuf.
sahnib Feb 6, 2024
8e2b193
Fixing things.
sahnib Feb 6, 2024
16e4c17
support timeMode for python state v2 API
bogao007 Jun 20, 2024
92ef716
Add protobuf for serde
sahnib Feb 13, 2024
c3eaf38
protobuf change
bogao007 Jun 20, 2024
609d94e
Initial commit
bogao007 Jun 27, 2024
a27f9d9
better error handling, support value state with different types
bogao007 Jun 28, 2024
684939b
addressed comments
bogao007 Jul 3, 2024
7f65fbd
fix
bogao007 Jul 3, 2024
c25d7da
Added support for unix domain socket
bogao007 Jul 11, 2024
9c8c616
removed unrelated log lines, addressed part of the comments
bogao007 Jul 17, 2024
c641192
fix
bogao007 Jul 17, 2024
8d3da4e
Addressed comments
bogao007 Jul 19, 2024
cc9bf95
removed unnecessary print
bogao007 Jul 19, 2024
f7df2dc
rename
bogao007 Jul 19, 2024
27cd169
fix
bogao007 Jul 19, 2024
3b5b3e5
removed duplicate proto file
bogao007 Jul 20, 2024
5d910d8
revert unrelated changes
bogao007 Jul 20, 2024
df859ab
fix
bogao007 Jul 20, 2024
654f2f6
Added unit tests for transformWithStateInPandas
bogao007 Jul 24, 2024
38832a6
Merge branch 'master' into state-v2-initial
bogao007 Jul 24, 2024
0585ac0
fix and rename
bogao007 Jul 24, 2024
0ee5029
update test
bogao007 Jul 24, 2024
6232c81
Added lisences
bogao007 Jul 25, 2024
41f8234
fixed format issues
bogao007 Jul 25, 2024
d57633f
fix
bogao007 Jul 25, 2024
df9ea9e
fix format
bogao007 Jul 25, 2024
68f7a7e
doc
bogao007 Jul 25, 2024
ca5216b
addressed comments
bogao007 Jul 26, 2024
c9e3a7c
structured log
bogao007 Jul 26, 2024
2320805
suppress auto generated proto file
bogao007 Jul 29, 2024
6e5de2e
fix linter
bogao007 Jul 29, 2024
200ec5e
fixed dependency issue
bogao007 Jul 29, 2024
dd3e46b
make protobuf as local dependency
bogao007 Jul 30, 2024
e8360d4
fix dependency issue
bogao007 Jul 30, 2024
82983af
fix
bogao007 Jul 30, 2024
49dbc16
fix lint
bogao007 Jul 30, 2024
d4e04ea
fix
bogao007 Jul 30, 2024
e108f60
updated fix
bogao007 Jul 30, 2024
bae26c2
reformat
bogao007 Jul 30, 2024
d96fa9e
addressed comments
bogao007 Jul 31, 2024
92531db
fix linter
bogao007 Jul 31, 2024
d507793
linter
bogao007 Jul 31, 2024
5dcb4c8
addressed comments
bogao007 Aug 2, 2024
37be02a
address comment
bogao007 Aug 2, 2024
f63687f
addressed comments
bogao007 Aug 9, 2024
263c087
Merge branch 'master' into state-v2-initial
bogao007 Aug 10, 2024
c7b0a4f
address comments
bogao007 Aug 12, 2024
c80b292
address comments
bogao007 Aug 12, 2024
81276f3
address comments
bogao007 Aug 14, 2024
5886b5c
fix lint
bogao007 Aug 14, 2024
23e54b4
fix lint
bogao007 Aug 14, 2024
2ba4fd0
address comments
bogao007 Aug 14, 2024
2a9c20b
fix test
bogao007 Aug 14, 2024
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
Prev Previous commit
Next Next commit
Fixing things.
  • Loading branch information
sahnib authored and bogao007 committed Jun 18, 2024
commit 8e2b193c6c4415ebcec0452a3767bd0959e5a4c6
2 changes: 1 addition & 1 deletion python/pyspark/sql/pandas/group_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def transformWithStateUDF(state_serializer: TransformWithStateInPandasStateSeria
state_serializer.handleState = StatefulProcessorHandleState.INITIALIZED

state_serializer.grouping_key_tracker.setKey(key[0])
result = stateful_processor.handle_input_rows(handle, key, inputRows)
result = stateful_processor.handle_input_rows(key, inputRows)

return result

Expand Down
31 changes: 25 additions & 6 deletions python/pyspark/sql/streaming/stateful_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#

from abc import ABC, abstractmethod
from typing import Any, TYPE_CHECKING, Iterator
from typing import Any, TYPE_CHECKING, Iterator, Union

from pyspark.sql.pandas.serializers import TransformWithStateInPandasStateSerializer
from pyspark.sql.streaming.gen import StateMessage_pb2
from pyspark.sql.types import DataType
from pyspark.sql.types import StructType

if TYPE_CHECKING:
from pyspark.sql.pandas._typing import DataFrameLike as PandasDataFrameLike
Expand Down Expand Up @@ -69,7 +69,7 @@ def __init__(
state_serializer: TransformWithStateInPandasStateSerializer) -> None:
self._state_serializer = state_serializer

def get_value_state(self, state_name: str, schema: DataType) -> ValueState:
def get_value_state(self, state_name: str, schema: Union[StructType, str]) -> ValueState:
get_value_state = StateMessage_pb2.StatefulProcessorHandleCall()
get_value_state.getValueState = StateMessage_pb2.GetValueState(state_name)

Expand All @@ -82,10 +82,29 @@ def get_value_state(self, state_name: str, schema: DataType) -> ValueState:

class StatefulProcessor(ABC):
@abstractmethod
def init(self, handle: StatefulProcessorHandle) -> None:
def init(self) -> None:
pass

@abstractmethod
def handle_input_rows(self, key: Any, handle: StatefulProcessorHandle,
rows: "PandasDataFrameLike") -> "PandasDataFrameLike":
def handle_input_rows(self, key: Any, rows: "PandasDataFrameLike") -> "PandasDataFrameLike":
pass

def getStatefulProcessorHandle(self) -> StatefulProcessorHandle:
pass


class WrappedStatefulProcessor(StatefulProcessor):

def __init__(self, handle: StatefulProcessorHandle,
udf_stateful_processor: StatefulProcessor) -> None:
self.handle = handle
self.udf_stateful_processor = udf_stateful_processor

def init(self) -> None:
self.udf_stateful_processor.init()

def handle_input_rows(self, key: Any, rows: "PandasDataFrameLike") -> "PandasDataFrameLike":
pass

def getStatefulProcessorHandle(self) -> StatefulProcessorHandle:
pass