Git Product home page Git Product logo

Comments (7)

eitsupi avatar eitsupi commented on May 28, 2024

It's also freeze.

"from a | select {b}" |> prqlr:::compile(target = NULL, format = FALSE, signature_comment = FALSE)

prqlc's output:

$ echo 'from a | select {b}' | prqlc compile
Error:
   ╭─[-:1:17]
   │
 1 │ from a | select {b}
   ·                 ┬
   ·                 ╰── unexpected {
───╯
Error:
   ╭─[-:1:19]
   │
 1 │ from a | select {b}
   ·                   ┬
   ·                   ╰── unexpected }
───╯

from prqlc-r.

eitsupi avatar eitsupi commented on May 28, 2024

Ok(prql_query).and_then(prql_compiler::prql_to_pl) seems to be the cause, because it does not hang up when changed as follows.

diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs
index 157c441..e762d28 100644
--- a/src/rust/src/lib.rs
+++ b/src/rust/src/lib.rs
@@ -17,7 +17,7 @@ pub fn compile(
     target: Option<String>,
     format: bool,
     signature_comment: bool,
-) -> List {
+) -> String {
     let options = convert_options(CompileOptions {
         format,
         target: target.unwrap_or("sql.any".to_string()),
@@ -27,13 +27,12 @@ pub fn compile(
     let result = options
         .and_then(|opts| {
             Ok(prql_query)
-                .and_then(prql_compiler::prql_to_pl)
-                .and_then(prql_compiler::pl_to_rq)
-                .and_then(|rq| prql_compiler::rq_to_sql(rq, &opts))
-        })
-        .map_err(|e| e.composed("", prql_query, false));
+                // .and_then(prql_compiler::prql_to_pl)
+                // .and_then(prql_compiler::pl_to_rq)
+                // .and_then(|rq| prql_compiler::rq_to_sql(rq, &opts))
+        });
 
-    r_result_list(result)
+    "out".to_string()
 }
 
 struct CompileOptions {

prql_to_pr also freezes.

"from a | select {b}" |> prqlr:::prql_to_pl()

from prqlc-r.

eitsupi avatar eitsupi commented on May 28, 2024

After all, the cause seems to be prql_compiler::prql_to_pl.
"from a | select {b}" |> prqlr:::prql_to_pl() hangs even if the following changes are made.

diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs
index 157c441..3341f67 100644
--- a/src/rust/src/lib.rs
+++ b/src/rust/src/lib.rs
@@ -57,12 +57,10 @@ fn convert_options(
 
 /// @noRd
 #[extendr]
-pub fn prql_to_pl(prql_query: &str) -> List {
-    let result = Ok(prql_query)
-        .and_then(prql_compiler::prql_to_pl)
-        .and_then(prql_compiler::json::from_pl);
+pub fn prql_to_pl(prql_query: &str) -> String {
+    let result = prql_compiler::prql_to_pl(prql_query);
 
-    r_result_list(result)
+    "out".to_string()
 }
 
 /// @noRd

from prqlc-r.

eitsupi avatar eitsupi commented on May 28, 2024

I thought it might be the length of the error message, but the following longer error message seems to work.......

> longstring <- rep(letters,1E4) |> paste0(collapse = "")

> longstring |> stringr::str_length()
[1] 260000

> prqlr:::compile("from a", target = longstring, format = FALSE, signature_comment = FALSE)
# works and shows a long error message

> prqlr:::compile(longstring, target = NULL, format = FALSE, signature_comment = FALSE)
# also works and shows a long error message

from prqlc-r.

eitsupi avatar eitsupi commented on May 28, 2024

prql-python via reticulate done not have a problem.

> prql <- reticulate::import("prql_python")

> prql$compile("from a | select {b}")
Error: SyntaxError: Error:
   ╭─[:1:17]
   │
 1from a | select {b}
   ·                 ┬
   ·                 ╰── unexpected {
───╯
Error:
   ╭─[:1:19]
   │
 1from a | select {b}
   ·                   ┬
   ·                   ╰── unexpected }
───╯

from prqlc-r.

eitsupi avatar eitsupi commented on May 28, 2024

When I check with htop, the process seems to keep running...

image

from prqlc-r.

eitsupi avatar eitsupi commented on May 28, 2024

In prqlc, "from a | select {{b" and "from a | select {{{b" cause the same error, but prqlr freezes only in the latter case!

> "from a | select {{b" |> prqlr:::prql_to_pl() |> prqlr:::unwrap()
Error in prqlr:::unwrap(prqlr:::prql_to_pl("from a | select {{b")) :
  Error:
   ╭─[:1:17]
   │
 1from a | select {{b
   ·                 ┬
   ·                 ╰── unexpected {
───╯

> "from a | select {{{b" |> prqlr:::prql_to_pl() |> prqlr:::unwrap()
# freeze 
$ echo 'from a | select {{b' | prqlc compile
Error:
   ╭─[-:1:17]
   │
 1 │ from a | select {{b
   ·                 ┬
   ·                 ╰── unexpected {
───╯
$ echo 'from a | select {{{b' | prqlc compile
Error:
   ╭─[-:1:17]
   │
 1 │ from a | select {{{b
   ·                 ┬
   ·                 ╰── unexpected {
───╯

from prqlc-r.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.