Apache Arrow에서 가져오기

Apache Arrow에서 가져오기

CREATE TABLE ASINSERT INTO는 어떤 쿼리로든 테이블을 만들거나 기존 테이블에 데이터를 넣을 수 있게 해줘요. 쿼리 안에서 Apache Arrow 객체를 그대로 참조하면 됩니다. 여기서는 Arrow Table에서 가져오는 예시를 보여드릴게요. DuckDB가 다루는 다양한 Apache Arrow 형식은 SQL on Arrow 가이드에서 확인할 수 있습니다.

출처: 공식문서

import duckdb
import pyarrow as pa

# connect to an in-memory database
my_arrow = pa.Table.from_pydict({'a': [42]})

# create the table "my_table" from the DataFrame "my_arrow"
duckdb.sql("CREATE TABLE my_table AS SELECT * FROM my_arrow")

# insert into the table "my_table" from the DataFrame "my_arrow"
duckdb.sql("INSERT INTO my_table SELECT * FROM my_arrow")

더 알아보기 (Learn more)

  • Arrow 객체를 쿼리에서 바로 참조하므로, 직접 바이너리로 변환하거나 중간 파일을 거칠 필요가 없어요.
  • Arrow Table·Dataset·Scanner·RecordBatchReader 등 다양한 형식의 지원은 SQL on Arrow 가이드를 참고하세요.