Skip to content

Commit

Permalink
feat: Move content from README to vignettes (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Jan 27, 2025
1 parent 4a83cbc commit 2bb53d4
Show file tree
Hide file tree
Showing 12 changed files with 1,042 additions and 347 deletions.
126 changes: 126 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at [email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
<https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][https://github.com/mozilla/inclusion].

For answers to common questions about this code of conduct, see the FAQ at
<https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.

[homepage]: https://www.contributor-covenant.org
6 changes: 3 additions & 3 deletions R/relational.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ check_funneled <- function(x, duckplyr_error, call = caller_env()) {
duckplyr_error_msg <- if (is.character(duckplyr_error)) duckplyr_error
duckplyr_error_parent <- if (is_condition(duckplyr_error)) duckplyr_error
cli::cli_abort(parent = duckplyr_error_parent, call = call, c(
"This operation cannot be carried out by DuckDB, and the input is a lazy duckplyr frame.",
"This operation cannot be carried out by DuckDB, and the input is a funneled duckplyr frame.",
"*" = duckplyr_error_msg,
"i" = "Use {.code compute(lazy = FALSE)} to materialize to temporary storage and continue with {.pkg duckplyr}.",
"i" = 'See the "Funneling" section in {.help duckdb_tibble} for other options.'
"i" = "Use {.code compute(funnel = FALSE)} to materialize to temporary storage and continue with {.pkg duckplyr}.",
"i" = 'See {.run vignette("funnel")} for other options.'
))
}
}
67 changes: 16 additions & 51 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ clean_output <- function(x, options) {
index <- strsplit(paste(index, collapse = "\n"), "\n---\n")[[1]][[2]]
writeLines(index, "index.md")
# FIXME: Change to the main site after release
x <- gsub('(`vignette[(]"([^"]+)"[)]`)', "[\\1](https://duckplyr.tidyverse.org/dev/articles/\\2.html)", x)
x <- fansi::strip_sgr(x)
x
}
Expand Down Expand Up @@ -130,14 +132,14 @@ class(out)
Nothing has been computed yet.
Querying the number of rows, or a column, starts the computation:

```{r}
```{r cache = TRUE}
out$month
```

Note that, unlike dplyr, the results are not ordered, see `?config` for details.
However, once materialized, the results are stable:

```{r}
```{r cache = TRUE}
out
```

Expand Down Expand Up @@ -168,7 +170,7 @@ db_exec("LOAD httpfs")
flights <- read_parquet_duckdb(urls)
```

Unlike with local data frames, the default is to disallow automatic materialization of the results on access.
Unlike with local data frames, the default is to disallow automatic materialization if the result is too large.

```{r error = TRUE}
nrow(flights)
Expand Down Expand Up @@ -213,62 +215,25 @@ Over 10M rows analyzed in about 10 seconds over the internet, that's not bad.
Of course, working with Parquet, CSV, or JSON files downloaded locally is possible as well.


## Using duckplyr in other packages
## Further reading

Refer to `vignette("developers", package = "duckplyr")`.
- `vignette("large")`: Tools for working with large data

## Telemetry
- `vignette("funnel")`: How duckplyr is both eager and lazy at the same time

As a drop-in replacement for dplyr, duckplyr will use DuckDB for the operations only if it can, and fall back to dplyr otherwise.
A fallback will not change the correctness of the results, but it may be slower or consume more memory.
We would like to guide our efforts towards improving duckplyr, focusing on the features with the most impact.
To this end, duckplyr collects and uploads telemetry data about fallback situations, but only if permitted by the user:
- `vignette("limits")`: Translation employed by duckplyr, and current limitations

- Collection is on by default, but can be turned off.
- Uploads are done upon request only.
- There is an option to automatically upload when the package is loaded, this is also opt-in.

The data collected contains:

- The package version
- The error message
- The operation being performed, and the arguments
- For the input data frames, only the structure is included (column types only), no column names or data

```{r include = FALSE}
Sys.setenv(DUCKPLYR_FALLBACK_COLLECT = "")
Sys.setenv(DUCKPLYR_FALLBACK_AUTOUPLOAD = "")
fallback_purge()
```
- `vignette("developers")`: Using duckplyr for individual data frames and in other packages

Fallback is silent by default, but can be made verbose.

```{r}
Sys.setenv(DUCKPLYR_FALLBACK_INFO = TRUE)
out <-
nycflights13::flights %>%
duckplyr::as_duckdb_tibble() %>%
mutate(inflight_delay = arr_delay - dep_delay)
```

After logs have been collected, the upload options are displayed the next time the duckplyr package is loaded in an R session.

```{r, echo = FALSE}
fallback_autoupload()
```
- `vignette("telemetry")`: Telemetry in duckplyr

The `fallback_sitrep()` function describes the current configuration and the available options.

## Getting help

## How is this different from dbplyr?
If you encounter a clear bug, please file an issue with a minimal reproducible example on [GitHub](https://github.com/tidyverse/duckplyr/issues). For questions and other discussion, please use [forum.posit.co](https://forum.posit.co/).

The duckplyr package is a dplyr backend that uses DuckDB, a high-performance, embeddable analytical database.
It is designed to be a fully compatible drop-in replacement for dplyr, with *exactly* the same syntax and semantics:

- Input and output are data frames or tibbles.
- All dplyr verbs are supported, with fallback.
- All R data types and functions are supported, with fallback.
- No SQL is generated.
## Code of conduct

The dbplyr package is a dplyr backend that connects to SQL databases, and is designed to work with various databases that support SQL, including DuckDB.
Data must be copied into and collected from the database, and the syntax and semantics are similar but not identical to plain dplyr.
Please note that this project is released with a [Contributor Code of Conduct](https://duckplyr.tidyverse.org/CODE_OF_CONDUCT).
By participating in this project you agree to abide by its terms.
106 changes: 31 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The following code aggregates the inflight delay by year and month for
the first half of the year. We use a variant of the
`nycflights13::flights` dataset, where the timezone has been set to UTC
to work around a current limitation of duckplyr, see
`vignette("limits.html")`.
[`vignette("limits.html")`](https://duckplyr.tidyverse.org/dev/articles/limits.html.html).

``` r
flights_df()
Expand Down Expand Up @@ -114,7 +114,7 @@ starts the computation:

``` r
out$month
#> [1] 2 4 5 1 3 6
#> [1] 4 1 3 6 2 5
```

Note that, unlike dplyr, the results are not ordered, see `?config` for
Expand All @@ -125,12 +125,12 @@ out
#> # A tibble: 6 × 4
#> year month mean_inflight_delay median_inflight_delay
#> <int> <int> <dbl> <dbl>
#> 1 2013 2 -5.15 -6
#> 2 2013 4 -2.67 -5
#> 3 2013 5 -9.37 -10
#> 4 2013 1 -3.86 -5
#> 5 2013 3 -7.36 -9
#> 6 2013 6 -4.24 -7
#> 1 2013 4 -2.67 -5
#> 2 2013 1 -3.86 -5
#> 3 2013 3 -7.36 -9
#> 4 2013 6 -4.24 -7
#> 5 2013 2 -5.15 -6
#> 6 2013 5 -9.37 -10
```

Restart R, or call `duckplyr::methods_restore()` to revert to the
Expand Down Expand Up @@ -168,11 +168,11 @@ flights <- read_parquet_duckdb(urls)
```

Unlike with local data frames, the default is to disallow automatic
materialization of the results on access.
materialization if the result is too large.

``` r
nrow(flights)
#> Error: Materialization is disabled, use collect() or as_tibble() to materialize.
#> Error: Materialization would result in 9091 rows, which exceeds the limit of 9090. Use collect() or as_tibble() to materialize.
```

Queries on the remote data are executed lazily, and the results are not
Expand Down Expand Up @@ -335,77 +335,33 @@ Over 10M rows analyzed in about 10 seconds over the internet, that’s not
bad. Of course, working with Parquet, CSV, or JSON files downloaded
locally is possible as well.

## Using duckplyr in other packages
## Further reading

Refer to `vignette("developers", package = "duckplyr")`.
- [`vignette("large")`](https://duckplyr.tidyverse.org/dev/articles/large.html):
Tools for working with large data

## Telemetry
- [`vignette("funnel")`](https://duckplyr.tidyverse.org/dev/articles/funnel.html):
How duckplyr is both eager and lazy at the same time

As a drop-in replacement for dplyr, duckplyr will use DuckDB for the
operations only if it can, and fall back to dplyr otherwise. A fallback
will not change the correctness of the results, but it may be slower or
consume more memory. We would like to guide our efforts towards
improving duckplyr, focusing on the features with the most impact. To
this end, duckplyr collects and uploads telemetry data about fallback
situations, but only if permitted by the user:
- [`vignette("limits")`](https://duckplyr.tidyverse.org/dev/articles/limits.html):
Translation employed by duckplyr, and current limitations

- Collection is on by default, but can be turned off.
- Uploads are done upon request only.
- There is an option to automatically upload when the package is loaded,
this is also opt-in.
- [`vignette("developers")`](https://duckplyr.tidyverse.org/dev/articles/developers.html):
Using duckplyr for individual data frames and in other packages

The data collected contains:
- [`vignette("telemetry")`](https://duckplyr.tidyverse.org/dev/articles/telemetry.html):
Telemetry in duckplyr

- The package version
- The error message
- The operation being performed, and the arguments
- For the input data frames, only the structure is included (column
types only), no column names or data
## Getting help

Fallback is silent by default, but can be made verbose.
If you encounter a clear bug, please file an issue with a minimal
reproducible example on
[GitHub](https://github.com/tidyverse/duckplyr/issues). For questions
and other discussion, please use
[forum.posit.co](https://forum.posit.co/).

``` r
Sys.setenv(DUCKPLYR_FALLBACK_INFO = TRUE)
out <-
nycflights13::flights %>%
duckplyr::as_duckdb_tibble() %>%
mutate(inflight_delay = arr_delay - dep_delay)
#> Error processing duckplyr query with DuckDB, falling back to dplyr.
#> Caused by error in `check_df_for_rel()` at duckplyr/R/relational-duckdb.R:108:3:
#> ! Attributes are lost during conversion. Affected column: `time_hour`.
```
## Code of conduct

After logs have been collected, the upload options are displayed the
next time the duckplyr package is loaded in an R session.

#> The duckplyr package is configured to fall back to dplyr when it encounters an
#> incompatibility. Fallback events can be collected and uploaded for analysis to
#> guide future development. By default, data will be collected but no data will
#> be uploaded.
#> ℹ Automatic fallback uploading is not controlled and therefore disabled, see
#> `?duckplyr::fallback()`.
#> ✔ Number of reports ready for upload: 1.
#> → Review with `duckplyr::fallback_review()`, upload with
#> `duckplyr::fallback_upload()`.
#> ℹ Configure automatic uploading with `duckplyr::fallback_config()`.

The `fallback_sitrep()` function describes the current configuration and
the available options.

## How is this different from dbplyr?

The duckplyr package is a dplyr backend that uses DuckDB, a
high-performance, embeddable analytical database. It is designed to be a
fully compatible drop-in replacement for dplyr, with *exactly* the same
syntax and semantics:

- Input and output are data frames or tibbles.
- All dplyr verbs are supported, with fallback.
- All R data types and functions are supported, with fallback.
- No SQL is generated.

The dbplyr package is a dplyr backend that connects to SQL databases,
and is designed to work with various databases that support SQL,
including DuckDB. Data must be copied into and collected from the
database, and the syntax and semantics are similar but not identical to
plain dplyr.
Please note that this project is released with a [Contributor Code of
Conduct](https://duckplyr.tidyverse.org/CODE_OF_CONDUCT). By
participating in this project you agree to abide by its terms.
Loading

0 comments on commit 2bb53d4

Please sign in to comment.