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

COPY TO api #30

Closed
wants to merge 1 commit into from
Closed

COPY TO api #30

wants to merge 1 commit into from

Conversation

aykut-bozkurt
Copy link
Collaborator

Add COPY TO parquet api, which internally executes COPY TO command via parquet dest receiver to write parquet file from the table or query.

let query = PgList::from_pg(rewritten_queries)
.pop()
.expect("rewritten query is empty");

Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: can probably capture the below in something like execute_query_into_destreceiver

if copy_stmt.attlist.is_null() {
let mut col_ref =
unsafe { PgBox::<pg_sys::ColumnRef>::alloc_node(pg_sys::NodeTag::T_ColumnRef) };
let a_star = unsafe { PgBox::<pg_sys::A_Star>::alloc_node(pg_sys::NodeTag::T_A_Star) };
Copy link
Collaborator

Choose a reason for hiding this comment

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

could use some more comments on the query we're constructing


use crate::parquet_copy_hook::copy_utils::{copy_has_relation, copy_lock_mode, copy_relation_oid};

pub(crate) fn execute_copy_to_with_dest_receiver(
Copy link
Collaborator

@marcoslot marcoslot Oct 2, 2024

Choose a reason for hiding this comment

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

could probably use a comment on what cleverness is going on here / how we can do COPY TO in a custom format with this one weird trick

per_copy_context: MemoryContext,
}

static mut PARQUET_WRITER_CONTEXT_STACK: Vec<ParquetWriterContext> = vec![];
Copy link
Collaborator

Choose a reason for hiding this comment

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

kind of neat, could use a comment on why we have this :)


let codec = parquet_dest.codec;

// create parquet writer context and push it to the stack
Copy link
Collaborator

Choose a reason for hiding this comment

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

general remark: I think comments on why we do something are a lot more useful than comments on what we do, since code itself is almost always clear on the latter, but not always on the former.

We internally execute COPY TO command via parquet dest receiver to write parquet file from the table or query.
@aykut-bozkurt
Copy link
Collaborator Author

Addressed at development branch.

@aykut-bozkurt aykut-bozkurt deleted the copy-to-api branch October 17, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants