jaychia commented on code in PR #9836: URL: https://github.com/apache/iceberg/pull/9836#discussion_r1515138488
########## docs/docs/daft.md: ########## @@ -0,0 +1,146 @@ +--- +title: "Daft" +--- +<!-- + - Licensed to the Apache Software Foundation (ASF) under one or more + - contributor license agreements. See the NOTICE file distributed with + - this work for additional information regarding copyright ownership. + - The ASF licenses this file to You under the Apache License, Version 2.0 + - (the "License"); you may not use this file except in compliance with + - the License. You may obtain a copy of the License at + - + - http://www.apache.org/licenses/LICENSE-2.0 + - + - Unless required by applicable law or agreed to in writing, software + - distributed under the License is distributed on an "AS IS" BASIS, + - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + - See the License for the specific language governing permissions and + - limitations under the License. + --> + +# Daft + +[Daft](www.getdaft.io) is a distributed query engine written in Python and Rust, two fast-growing ecosystems in the data engineering and machine learning industry. + +It exposes its flavor of the familiar [Python DataFrame API](https://www.getdaft.io/projects/docs/en/latest/api_docs/dataframe.html) which is a common abstraction over querying tables of data in the Python data ecosystem. + +Daft DataFrames are a powerful interface to power use-cases across ML/AI training, batch inference, feature engineering and traditional analytics. Daft's tight integration with Iceberg unlocks novel capabilities for both traditional analytics and Pythonic ML workloads on your data catalog. + +## Enabling Iceberg support in Daft + +[PyIceberg](https://py.iceberg.apache.org/) supports reading of Iceberg tables into Daft DataFrames. + +To use Iceberg with Daft, ensure that the [PyIceberg](https://py.iceberg.apache.org/) library is also installed in your current Python environment. + +``` +pip install getdaft pyiceberg +``` + +## Querying Iceberg using Daft + +Daft interacts natively with [PyIceberg](https://py.iceberg.apache.org/) to read Iceberg tables. + +### Reading Iceberg tables + +> **Setup Steps** +> +> To follow along with this code, first create an Iceberg table following [the spark-quickstart tutorial](https://iceberg.apache.org/spark-quickstart/). PyIceberg must then be correctly configured by ensuring that our `~/.pyiceberg.yaml` file contains an appropriate catalog entry: +> +> ``` +> catalog: +> default: +> # URL to the Iceberg REST server Docker container +> uri: http://localhost:8181 +> # URL and credentials for the MinIO Docker container +> s3.endpoint: http://localhost:9000 +> s3.access-key-id: admin +> s3.secret-access-key: password +> ``` + +Here is how we can load the Iceberg table `demo.nyc.taxis` into Daft: + +``` py +import daft +from pyiceberg.catalog import load_catalog + +# Configure Daft to use the local MinIO Docker container for any S3 operations +daft.set_planning_config( + default_io_config=daft.io.IOConfig( + s3=daft.io.S3Config(endpoint_url="http://localhost:9000"), + ) +) + +# Load a PyIceberg table into Daft, and show the first few rows +table = load_catalog("default").load_table("nyc.taxis") +df = daft.read_iceberg(table) +df.show() +``` + +``` +WARNING:root:IcebergScanOperator(default.nyc.taxis) has Partitioning Keys: [PartitionField(vendor_id#Int64, src=vendor_id#Int64, tfm=Identity)] but no partition filter was specified. This will result in a full table scan. Review Comment: I thought it would be helpful in demonstrating the predicate pushdowns, but I can remove this as well since it does feel a little confusing! -- 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. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org