stephhazlitt commented on code in PR #159: URL: https://github.com/apache/arrow-cookbook/pull/159#discussion_r1006295413
########## r/content/datasets.Rmd: ########## @@ -0,0 +1,291 @@ +<!--- + 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. +--> + +# Manipulating Data - Datasets + +## Introduction + +While Arrow allows you to work with single files imported as Arrow Tables, you can +also work with multi-files imported as an Arrow Dataset. Partitioning allows you to split data across +multiple files/folders, avoiding problems associated with storing all your data in a single file. This can provide +further advantages when using Arrow, as Arrow will only +read in the necessary partitioned files needed for any given analysis. + +It's possible to read in partitioned data in Parquet, Feather (aka Arrow), and CSV (or +other text-delimited) formats. If you are choosing a partitioned or multifile format, we +recommend Parquet or Feather, both of which can have improved performance +when compared to CSVs due to their capabilities around metadata and compression. + +## Write a data to disk (Parquet) + +You want to write data to disk in a single Parquet file. + +### Solution + +```{r, write_dataset_basic} +write_dataset(dataset = starwars, path = "starwars_data") +``` + +```{r, test_write_dataset_basic, opts.label = "test"} + +test_that("write_dataset_basic works as expected", { + + expect_true(file.exists("starwars_data")) + expect_length(list.files("starwars_data"), 1) + Review Comment: Done! -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
