morningman commented on a change in pull request #4858:
URL: https://github.com/apache/incubator-doris/pull/4858#discussion_r518767656
##########
File path: be/src/exec/schema_scanner/schema_columns_scanner.cpp
##########
@@ -250,20 +265,33 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple,
MemPool *pool) {
memcpy(str_slot->ptr, buffer.c_str(), str_slot->len);
}
// CHARACTER_MAXIMUM_LENGTH
+ // For string columns, the maximum length in characters.
{
- tuple->set_null(_tuple_desc->slots()[8]->null_indicator_offset());
+ int data_type =
_desc_result.columns[_column_index].columnDesc.columnType;
+ if (data_type == TPrimitiveType::VARCHAR || data_type ==
TPrimitiveType::CHAR) {
+ void *slot =
tuple->get_slot(_tuple_desc->slots()[8]->tuple_offset());
+ int64_t* str_slot = reinterpret_cast<int64_t*>(slot);
+ if
(_desc_result.columns[_column_index].columnDesc.__isset.columnLength) {
+ *str_slot =
_desc_result.columns[_column_index].columnDesc.columnLength;
+ } else {
+
tuple->set_null(_tuple_desc->slots()[8]->null_indicator_offset());
+ }
+ } else {
+ tuple->set_null(_tuple_desc->slots()[8]->null_indicator_offset());
+ }
}
// CHARACTER_OCTET_LENGTH
+ // For string columns, the maximum length in bytes.
{
int data_type =
_desc_result.columns[_column_index].columnDesc.columnType;
if (data_type == TPrimitiveType::VARCHAR || data_type ==
TPrimitiveType::CHAR) {
void *slot =
tuple->get_slot(_tuple_desc->slots()[9]->tuple_offset());
int64_t* str_slot = reinterpret_cast<int64_t*>(slot);
if
(_desc_result.columns[_column_index].columnDesc.__isset.columnLength) {
- *str_slot =
_desc_result.columns[_column_index].columnDesc.columnLength;
+ *str_slot =
_desc_result.columns[_column_index].columnDesc.columnLength * 4;
Review comment:
Why 4?
##########
File path: be/src/exec/schema_scanner/schema_columns_scanner.cpp
##########
@@ -236,9 +238,22 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple,
MemPool *pool) {
{
void *slot = tuple->get_slot(_tuple_desc->slots()[6]->tuple_offset());
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
- str_slot->len = strlen("NO") + 1;
- str_slot->ptr = (char *)pool->allocate(str_slot->len);
- memcpy(str_slot->ptr, "NO", str_slot->len);
+
+ if
(_desc_result.columns[_column_index].columnDesc.__isset.isAllowNull) {
+ if (_desc_result.columns[_column_index].columnDesc.isAllowNull) {
+ str_slot->len = strlen("YES");
Review comment:
No need to plus 1?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]