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

Add export tasks #2450

Merged
merged 74 commits into from
Feb 20, 2025
Merged

Add export tasks #2450

merged 74 commits into from
Feb 20, 2025

Conversation

inv-jishnu
Copy link
Contributor

@inv-jishnu inv-jishnu commented Jan 6, 2025

Description

In this PR I have added classes and dtos for export tasks which processes the data to be exported for supported export file formats (JSON, JSONLines and CSV).

Related issues and/or PRs

Please review and merge this PR once the following PRs are merged

Changes made

Added producer tasks to generate export output files

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

Road map to merge remaining data loader core files. Current status

Release notes

NA

@inv-jishnu inv-jishnu requested a review from komamitsu February 12, 2025 10:47
@Override
void processHeader(ExportOptions exportOptions, TableMetadata tableMetadata, Writer writer)
throws IOException {
System.out.println("SSSSSSSSSSSSSSSSSSSSSSSS");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is for debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I forgot to remove it.
Removed it now.
Thank you.

@Override
void processFooter(ExportOptions exportOptions, TableMetadata tableMetadata, Writer writer)
throws IOException {
System.out.println("SSSSSSSSSSSSSSSSSSSSSSSS");
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it now.
Thank you.

// TODO: handle this
}
processFooter(exportOptions, tableMetadata, bufferedWriter);
bufferedWriter.flush();
Copy link
Contributor

Choose a reason for hiding this comment

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

BufferedWriter has its own buffer to contain tentative content to write. Even if the original Writer instance is closed, the buffered content can be lost if any exception is thrown before calling bufferedWriter.flush(). I think this should be called in finally block.

@inv-jishnu inv-jishnu requested a review from komamitsu February 13, 2025 04:32
Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

case BOOLEAN:
value = Boolean.toString(result.getBoolean(columnName));
break;
case TEXT:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a reminder just in case: please add support for the new data types DATE, TIME, TIMESTAMP, and TIMESTAMPTZ in the Data Loader at some point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

private final boolean prettyPrintJson;

/**
* *
Copy link
Contributor

Choose a reason for hiding this comment

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

A part of the Javadoc seems to be missing.

Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

Left several comments. Please take a look when you have time!

case BOOLEAN:
value = Boolean.toString(result.getBoolean(columnName));
break;
case TEXT:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines 147 to 149
default:
logger.error(
CoreError.DATA_LOADER_CONVERT_TO_STRING_FAILED.buildMessage(dataType.toString()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can throw an AssertionError since this code should never be reached.

Suggested change
default:
logger.error(
CoreError.DATA_LOADER_CONVERT_TO_STRING_FAILED.buildMessage(dataType.toString()));
default:
throw new AssertionError("Unkown data type:" + dataType);

Comment on lines 121 to 124
default:
logger.error(
CoreError.DATA_LOADER_CONVERT_TO_STRING_FAILED.buildMessage(dataType.toString()));
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Diito. We can throw an AssertionError since this code should never be reached.

Comment on lines 132 to 134
default:
logger.error(
CoreError.DATA_LOADER_CONVERT_TO_STRING_FAILED.buildMessage(dataType.toString()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto. We can throw an AssertionError since this code should never be reached.

@brfrn169 brfrn169 self-requested a review February 14, 2025 02:05
Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

Left a comment. Other than that, LGTM. Thank you!

@@ -1079,6 +1087,12 @@ public enum CoreError implements ScalarDbError {
"Something went wrong while scanning. Are you sure you are running in the correct transaction mode? Details: %s",
"",
""),
DATA_LOADER_CONVERT_TO_STRING_FAILED(
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that this message is no longer needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed it in 2828244.
Thank you.

@ypeckstadt ypeckstadt merged commit 75f8a9c into master Feb 20, 2025
48 checks passed
@ypeckstadt ypeckstadt deleted the feat/data-loader/export-tasks branch February 20, 2025 08:01
feeblefakie pushed a commit that referenced this pull request Feb 20, 2025
Co-authored-by: Peckstadt Yves <[email protected]>
feeblefakie pushed a commit that referenced this pull request Feb 20, 2025
Co-authored-by: Peckstadt Yves <[email protected]>
feeblefakie pushed a commit that referenced this pull request Feb 20, 2025
Co-authored-by: Peckstadt Yves <[email protected]>
feeblefakie pushed a commit that referenced this pull request Feb 20, 2025
Co-authored-by: Peckstadt Yves <[email protected]>
feeblefakie pushed a commit that referenced this pull request Feb 20, 2025
Co-authored-by: Peckstadt Yves <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants