Skip to content

Commit

Permalink
access layer
Browse files Browse the repository at this point in the history
Signed-off-by: tabVersion <[email protected]>
  • Loading branch information
tabVersion committed Sep 6, 2024
1 parent 20f6bfa commit 6daffc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/connector/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,16 @@ impl SourceStreamChunkRowWriter<'_> {
.map(|ele| ScalarRefImpl::Utf8(ele.split_id)),
));
}
(_, &Some(AdditionalColumnType::Payload(_))) => {
// Get the whole payload as a single column
// The frontend check guarantees that row encode must be `SourceEncode::Json`
// here fake a column named "." to represent the whole payload
// see the json accessor hack in `impl Access for JsonAccess<'_>`
let mut desc_mock = desc.clone();
desc_mock.name = ".".to_string();
desc_mock.additional_column.column_type = None;
parse_field(&desc_mock)
}
(_, _) => {
// For normal columns, call the user provided closure.
parse_field(desc)
Expand Down
4 changes: 4 additions & 0 deletions src/connector/src/parser/unified/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ impl<'a> JsonAccess<'a> {
impl Access for JsonAccess<'_> {
fn access<'a>(&'a self, path: &[&str], type_expected: &DataType) -> AccessResult<DatumCow<'a>> {
let mut value = &self.value;
if path.len() == 1 && path[0] == "." {
return self.options.parse(value, type_expected);
}

for (idx, &key) in path.iter().enumerate() {
if let Some(sub_value) = if self.options.ignoring_keycase {
json_object_get_case_insensitive(value, key)
Expand Down

0 comments on commit 6daffc2

Please sign in to comment.