pola-rs / r-polars

Bring polars to R
https://pola-rs.github.io/r-polars/
Other
398 stars 35 forks source link

feat: experimental `$sql()` method for LazyFrame and DataFrame #1065

Closed eitsupi closed 2 weeks ago

eitsupi commented 2 weeks ago

Same as pola-rs/polars#15783

eitsupi commented 2 weeks ago

Hmmm, there seems to be errors in building the website. Perhaps a problem with the < escaping process?

eitsupi commented 2 weeks ago

I checked altdoc:::.rd2qmd("man/DataFrame_sql.Rd", ".", "."). The output qmd file has this:

# Apply transformations to a DataFrame using SQL, aliasing "self" to "frame".
df1$sql(
  query = r"(
SELECT
a,
(a \% 2 == 0) AS a_is_even,
CONCAT_WS(':', b, b) AS b_b,
EXTRACT(year FROM c) AS year,
0::float AS 'zero'
FROM frame
)",
  table_name = "frame"
)

\% should be replaced to %.

eitsupi commented 2 weeks ago

It seems that this is a bug of tools::parse_Rd().

eitsupi commented 2 weeks ago

In /tmp/test.Rd

\examples{
a <- "\%"
b <- "
\%
"
c <- r"(
\%
)"
}
> tools::parse_Rd("/tmp/test.Rd")
\examples{
a <- "%"
b <- "
%
"
c <- r"(
\%
)"
}
eitsupi commented 2 weeks ago

Apparently this is a bug in roxygen2. The following Rd file is fine, so no % escaping is needed here.

\examples{
a <- "\%"
b <- "
%
"
c <- r"(
%
)"
}

I opened an issue r-lib/roxygen2#1616

eitsupi commented 2 weeks ago

For now, we can use MOD(x, 2) instead of x % 2 to avoid using % in examples.

eitsupi commented 2 weeks ago

This is a new experimental method addition that does not affect existing code. So merging.