julia smartreceive table defaults to a dataframe

This commit is contained in:
2026-03-10 12:06:31 +07:00
parent 99f1b2e720
commit 8f50039a68
2 changed files with 11 additions and 8 deletions

View File

@@ -931,8 +931,8 @@ It handles "text" (string), "dictionary" (JSON deserialization), "arrowtable" (A
2. Converts bytes to appropriate Julia data type based on format
3. For text: converts bytes to string
4. For dictionary: converts bytes to JSON string then parses to Julia object
5. For arrowtable: reads Arrow IPC format and returns Arrow.Table
6. For jsontable: converts bytes to JSON string then parses to Vector{Dict}
5. For arrowtable: reads Arrow IPC format and returns a DataFrame
6. For jsontable: converts bytes to JSON string then parses to Vector{Dict} and return a DataFrame
7. For image/audio/video/binary: returns bytes directly
# Arguments:
@@ -958,11 +958,11 @@ json_data = _deserialize_data(json_bytes, "dictionary", "correlation123")
# Arrow IPC data (arrowtable)
arrow_bytes = Vector{UInt8}([1, 2, 3]) # Arrow IPC bytes
arrow_table = _deserialize_data(arrow_bytes, "arrowtable", "correlation123")
df = _deserialize_data(arrow_bytes, "arrowtable", "correlation123")
# JSON table data (jsontable)
json_table_bytes = UInt8[91, 123, 34, 105, 100, 34, 58, 49, 44, 34, 110, 97, 109, 101, 34, 58, 34, 65, 108, 105, 99, 101, 34, 125] # [{"id":1,"name":"Alice"}]
json_table = _deserialize_data(json_table_bytes, "jsontable", "correlation123")
df = _deserialize_data(json_table_bytes, "jsontable", "correlation123")
```
"""
function _deserialize_data(
@@ -977,11 +977,14 @@ function _deserialize_data(
return JSON.parse(json_str) # Parse JSON string to JSON object
elseif payload_type == "arrowtable" # Arrow table data - deserialize Arrow IPC stream
io = IOBuffer(data) # Create buffer from bytes
table = Arrow.Table(io) # Read Arrow IPC format from buffer
return table # Return Arrow.Table
arrowtable = Arrow.Table(io) # Read Arrow IPC format from buffer
df = DataFrame(arrowtable)
return df
elseif payload_type == "jsontable" # JSON table data - deserialize JSON
json_str = String(data) # Convert bytes to string
return JSON.parse(json_str) # Parse JSON string to Vector{Dict}
jsontable = JSON.parse(json_str) # Parse JSON string to jsontable i.e. Vector{Dict}
df = DataFrame(jsontable)
return df
elseif payload_type == "image" # Image data - return binary
return data # Return bytes directly
elseif payload_type == "audio" # Audio data - return binary