You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "jonahgao (via GitHub)" <gi...@apache.org> on 2024/11/09 14:26:53 UTC
[PR] feat: support `DEALLOCATE` to remove prepared statements [datafusion]
jonahgao opened a new pull request, #13327:
URL: https://github.com/apache/datafusion/pull/13327
## Which issue does this PR close?
Follow-up of #13242
## Rationale for this change
Support the `DEALLOCATE` sql statement to remove prepared plans.
A typical usage is
```sh
> prepare p(int) as select $1;
0 row(s) fetched.
Elapsed 0.003 seconds.
> deallocate p;
0 row(s) fetched.
Elapsed 0.002 seconds.
```
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
Yes
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
No
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `DEALLOCATE` to remove prepared statements [datafusion]
Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on code in PR #13327:
URL: https://github.com/apache/datafusion/pull/13327#discussion_r1835700101
##########
datafusion/sqllogictest/test_files/prepare.slt:
##########
@@ -77,6 +81,28 @@ EXECUTE my_plan('Foo', 'Bar');
statement error Prepared statement \'my_plan\' already exists
PREPARE my_plan(STRING, STRING) AS SELECT * FROM (VALUES(1, $1), (2, $2)) AS t (num, letter);
+# deallocate a plan
+statement ok
+DEALLOCATE my_plan;
+
+# can't EXECUTE a deallocated plan
+statement error Prepared statement \'my_plan\' does not exist
+EXECUTE my_plan('Foo', 'Bar');
+
+# re-prepare a deallocated plan
+statement ok
+PREPARE my_plan(STRING, STRING) AS SELECT * FROM (VALUES(1, $1), (2, $2)) AS t (num, letter);
+
+query IT
+EXECUTE my_plan('Foo', 'Bar');
+----
+1 Foo
+2 Bar
+
+# deallocate with the PREPARE keyword
+statement ok
+DEALLOCATE PREPARE my_plan;
+
Review Comment:
I think we can simplify the test to
```suggestion
# deallocate a plan
statement ok
DEALLOCATE my_plan;
# can't EXECUTE a deallocated plan
statement error Prepared statement \'my_plan\' does not exist
EXECUTE my_plan('Foo', 'Bar');
```
1. Test Deallcocate
2. Test the deallocated query can't be executed.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `DEALLOCATE` to remove prepared statements [datafusion]
Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on PR #13327:
URL: https://github.com/apache/datafusion/pull/13327#issuecomment-2466749299
Thanks @jatin510 @goldmedal for the review
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `DEALLOCATE` to remove prepared statements [datafusion]
Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on code in PR #13327:
URL: https://github.com/apache/datafusion/pull/13327#discussion_r1835701840
##########
datafusion/sqllogictest/test_files/prepare.slt:
##########
@@ -77,6 +81,28 @@ EXECUTE my_plan('Foo', 'Bar');
statement error Prepared statement \'my_plan\' already exists
PREPARE my_plan(STRING, STRING) AS SELECT * FROM (VALUES(1, $1), (2, $2)) AS t (num, letter);
+# deallocate a plan
+statement ok
+DEALLOCATE my_plan;
+
+# can't EXECUTE a deallocated plan
+statement error Prepared statement \'my_plan\' does not exist
+EXECUTE my_plan('Foo', 'Bar');
+
+# re-prepare a deallocated plan
+statement ok
+PREPARE my_plan(STRING, STRING) AS SELECT * FROM (VALUES(1, $1), (2, $2)) AS t (num, letter);
+
+query IT
+EXECUTE my_plan('Foo', 'Bar');
+----
+1 Foo
+2 Bar
+
+# deallocate with the PREPARE keyword
+statement ok
+DEALLOCATE PREPARE my_plan;
+
Review Comment:
Hmmm, I rethink it. I think we should test it to be deallocated and re-prepare again. Let's keep your version 👍
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `DEALLOCATE` to remove prepared statements [datafusion]
Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on code in PR #13327:
URL: https://github.com/apache/datafusion/pull/13327#discussion_r1835700101
##########
datafusion/sqllogictest/test_files/prepare.slt:
##########
@@ -77,6 +81,28 @@ EXECUTE my_plan('Foo', 'Bar');
statement error Prepared statement \'my_plan\' already exists
PREPARE my_plan(STRING, STRING) AS SELECT * FROM (VALUES(1, $1), (2, $2)) AS t (num, letter);
+# deallocate a plan
+statement ok
+DEALLOCATE my_plan;
+
+# can't EXECUTE a deallocated plan
+statement error Prepared statement \'my_plan\' does not exist
+EXECUTE my_plan('Foo', 'Bar');
+
+# re-prepare a deallocated plan
+statement ok
+PREPARE my_plan(STRING, STRING) AS SELECT * FROM (VALUES(1, $1), (2, $2)) AS t (num, letter);
+
+query IT
+EXECUTE my_plan('Foo', 'Bar');
+----
+1 Foo
+2 Bar
+
+# deallocate with the PREPARE keyword
+statement ok
+DEALLOCATE PREPARE my_plan;
+
Review Comment:
I think we can simplify the test to
```suggestion
query IT
EXECUTE my_plan('Foo', 'Bar');
----
1 Foo
2 Bar
# deallocate a plan
statement ok
DEALLOCATE my_plan;
# can't EXECUTE a deallocated plan
statement error Prepared statement \'my_plan\' does not exist
EXECUTE my_plan('Foo', 'Bar');
```
1. Test the preparation works.
2. Test Deallcocate
3. Test the deallocated query can't be executed.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `DEALLOCATE` to remove prepared statements [datafusion]
Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao merged PR #13327:
URL: https://github.com/apache/datafusion/pull/13327
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org