Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support to recognize skip.header.line.count in hive's textfile #47001

Merged
merged 5 commits into from
Jun 17, 2024

Conversation

Smith-Cruise
Copy link
Contributor

@Smith-Cruise Smith-Cruise commented Jun 14, 2024

Why I'm doing:

Support skip.header.line.count tblproperties in hive table.

demo:

create table csv_big_skip
(c1 string, c2 int) stored as textfile tblproperties("skip.header.line.count"="10");

What I'm doing:

Support it

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

Signed-off-by: Smith Cruise <chendingchao1@126.com>
Signed-off-by: Smith Cruise <chendingchao1@126.com>
Signed-off-by: Smith Cruise <chendingchao1@126.com>
@Smith-Cruise Smith-Cruise requested review from a team as code owners June 14, 2024 06:12
@wanpengfei-git wanpengfei-git requested a review from a team June 14, 2024 06:13
@Smith-Cruise Smith-Cruise changed the title [Feature] Support to recognize skip.header.line.count in hive's textfile [Enhancement] Support to recognize skip.header.line.count in hive's textfile Jun 14, 2024
Signed-off-by: Smith Cruise <chendingchao1@126.com>
if (text_file_desc.__isset.compression_type) {
_compression_type = CompressionUtils::to_compression_pb(text_file_desc.compression_type);
compression_type = CompressionUtils::to_compression_pb(text_file_desc.compression_type);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

String mapkeyDelim = serdeParams.getOrDefault("mapkey.delim", "");
String lineDelim = parameters.getOrDefault(serdeConstants.LINE_DELIM, "");
String mapkeyDelim = parameters.getOrDefault(serdeConstants.MAPKEY_DELIM, "");
int skipHeaderLineCount = Integer.parseInt(parameters.getOrDefault(serdeConstants.HEADER_COUNT, "0"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better check if it's legit, such as >= 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Status _create_csv_reader();
Status _setup_compression_type(const TTextFileDesc& text_file_desc);
Status _setup_delimiter(const TTextFileDesc& text_file_desc);
StatusOr<bool> _has_uft8_bom() const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo for utf8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: Smith Cruise <chendingchao1@126.com>
Copy link

Copy link

[FE Incremental Coverage Report]

pass : 21 / 22 (95.45%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/connector/hive/HiveMetastoreApiConverter.java 14 15 93.33% [594]
🔵 com/starrocks/connector/hive/TextFileFormatDesc.java 7 7 100.00% []

Copy link

[BE Incremental Coverage Report]

pass : 57 / 57 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/exec/hdfs_scanner.cpp 6 6 100.00% []
🔵 be/src/exec/hdfs_scanner_text.cpp 51 51 100.00% []

@@ -627,4 +628,12 @@ void HdfsScanner::move_split_tasks(std::vector<pipeline::ScanSplitContextPtr>* s
}
}

CompressionTypePB HdfsScanner::get_compression_type_from_path(const std::string& filename) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate with the function return_compression_type_from_filename of hdf_scanner_text.cpp ?

Make it to one common function?

@@ -100,6 +100,8 @@ struct TTextFileDesc {

// escape character
8: optional i8 escape

9: optional i32 skip_header_line_count
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After adding this Skip, will it cause problems with the optimizer, such as Limit 1. In the past, FE would select 1 file, but with this skip, problems may occur?

@trueeyu trueeyu merged commit 2c838f7 into StarRocks:main Jun 17, 2024
61 of 63 checks passed
Copy link

@Mergifyio backport branch-3.3

@github-actions github-actions bot removed the 3.3 label Jun 17, 2024
Copy link

@Mergifyio backport branch-3.2

Copy link

@Mergifyio backport branch-3.1

Copy link
Contributor

mergify bot commented Jun 17, 2024

backport branch-3.3

✅ Backports have been created

Copy link
Contributor

mergify bot commented Jun 17, 2024

backport branch-3.2

✅ Backports have been created

Copy link
Contributor

mergify bot commented Jun 17, 2024

backport branch-3.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jun 17, 2024
…extfile (#47001)

Signed-off-by: Smith Cruise <chendingchao1@126.com>
(cherry picked from commit 2c838f7)
mergify bot pushed a commit that referenced this pull request Jun 17, 2024
…extfile (#47001)

Signed-off-by: Smith Cruise <chendingchao1@126.com>
(cherry picked from commit 2c838f7)

# Conflicts:
#	be/src/exec/hdfs_scanner_text.cpp
#	be/src/exec/hdfs_scanner_text.h
#	fe/fe-core/src/main/java/com/starrocks/connector/hive/TextFileFormatDesc.java
#	fe/fe-core/src/test/java/com/starrocks/connector/hive/HiveMetaClientTest.java
#	fe/fe-core/src/test/java/com/starrocks/connector/hive/TextFileFormatDescTest.java
mergify bot pushed a commit that referenced this pull request Jun 17, 2024
…extfile (#47001)

Signed-off-by: Smith Cruise <chendingchao1@126.com>
(cherry picked from commit 2c838f7)

# Conflicts:
#	be/src/exec/hdfs_scanner.cpp
#	be/src/exec/hdfs_scanner_text.cpp
#	be/src/exec/hdfs_scanner_text.h
#	be/test/exec/hdfs_scanner_test.cpp
#	fe/fe-core/src/main/java/com/starrocks/connector/hive/HiveMetastoreApiConverter.java
#	fe/fe-core/src/main/java/com/starrocks/connector/hive/TextFileFormatDesc.java
#	fe/fe-core/src/test/java/com/starrocks/connector/hive/HiveMetaClientTest.java
#	fe/fe-core/src/test/java/com/starrocks/connector/hive/TextFileFormatDescTest.java
@Smith-Cruise Smith-Cruise deleted the csv-skip-header branch June 17, 2024 05:01
wanpengfei-git pushed a commit that referenced this pull request Jun 17, 2024
…extfile (backport #47001) (#47078)

Co-authored-by: Smith Cruise <chendingchao1@126.com>
packy92 pushed a commit that referenced this pull request Jun 17, 2024
…er.line.count in hive's textfile (backport #47001) (#47082)

Signed-off-by: Smith Cruise <chendingchao1@126.com>
smartlxh pushed a commit to smartlxh/starrocks that referenced this pull request Oct 16, 2024
… skip.header.line.count in hive's textfile (backport StarRocks#47001) (StarRocks#47082)

Signed-off-by: Smith Cruise <chendingchao1@126.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants