ydb icon indicating copy to clipboard operation
ydb copied to clipboard

`ReadRows` ignores nullability of columns

Open alex268 opened this issue 7 months ago • 0 comments

When we have a table with nullable columns - readRows returns the same protobuf message for empty and null values. For example, I can execute next bulkUpsert on a simple table with two columns - not null id and nullable text.

rows {
  type { list_type { item { struct_type {
    members { name: "id" type { type_id: UINT32 } }
    members { name: "text" type { type_id: UTF8 } }
  } } } }
  value {
    items { items { uint32_value: 1 } items { text_value: "id1" } }
    items { items { uint32_value: 2 } items { text_value: "" } }
    items { items { uint32_value: 3 } items { null_flag_value: NULL_VALUE } }
  }
}

After that, when I read these rows via readTable method I got a message

result_set {
  columns { name: "id"   type { optional_type { item { type_id: UINT32 } } } }
  columns { name: "text" type { optional_type { item { type_id: UTF8   } } } }
  rows { items { uint32_value: 1 } items { text_value: "id1" } }
  rows { items { uint32_value: 2 } items { text_value: "" } }
  rows { items { uint32_value: 3 } items { null_flag_value: NULL_VALUE } }
  truncated: true
}

All three rows have different values for column text But if I read these rows via readRows method - I got next response

result_set {
  columns { name: "id"   type { type_id: UINT32 } }
  columns { name: "text" type { type_id: UTF8   } }
  rows { items { uint32_value: 1 } items { text_value: "id1" } }
  rows { items { uint32_value: 2 } items { text_value: "" } }
  rows { items { uint32_value: 3 } items { text_value: "" } }
}

Second and third rows have the equals values for column text

alex268 avatar Jul 02 '24 16:07 alex268