Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use CTE and read_html() function #17

Closed
marcoarthur opened this issue Sep 17, 2024 · 3 comments
Closed

Cannot use CTE and read_html() function #17

marcoarthur opened this issue Sep 17, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@marcoarthur
Copy link

Trying to select more than one selector I wrote the following CTE
But, anyquery returned this error:

anyquery> WITH files AS (
.........   SELECT * FROM read_html('http://localhost:8000/', '.mtime')
.........   UNION
.........   SELECT * FROM read_html('http://localhost:8000/', '.size')
......... )
......... SELECT * 
......... FROM files;
no such table: read_html
anyquery> 

But I am able to run the SELECT outside the CTE:

anyquery> SELECT * FROM read_html('http://localhost:8000/', '.mtime');
+----------+-------------------------------+--------------------------------------+
| tag_name |            content            |              attributes              |
+----------+-------------------------------+--------------------------------------+
| td       | Wed, 21 Aug 2024 14:13:54 GMT | [{"Namespace":"","Key":"class","Val" |
|          |                               | :"mtime"}]                           |
| td       | Wed, 21 Aug 2024 14:18:21 GMT | [{"Namespace":"","Key":"class","Val" |
|          |                               | :"mtime"}]                           |
| td       | Wed, 21 Aug 2024 14:13:54 GMT | [{"Namespace":"","Key":"class","Val" |
|          |                               | :"mtime"}]                           |
| td       | Wed, 21 Aug 2024 14:15:45 GMT | [{"Namespace":"","Key":"class","Val" |
|          |                               | :"mtime"}]                           |
| td       | Mon, 16 Sep 2024 13:51:08 GMT | [{"Namespace":"","Key":"class","Val" |
|          |                               | :"mtime"}]                           |
+----------+-------------------------------+--------------------------------------+

My anyquery: anyquery version 0.1.3 (built with go1.22.6 for linux/amd64)

@julien040
Copy link
Owner

Thank you for reporting this, @marcoarthur.
The issue will be fixed in the next release.

I'll ping you when I release it.

@julien040 julien040 self-assigned this Sep 18, 2024
@julien040 julien040 added the bug Something isn't working label Sep 18, 2024
julien040 added a commit that referenced this issue Sep 19, 2024
Now, the SQL query rewriter for read_ queries takes care of CTEs too
@julien040
Copy link
Owner

Hey @marcoarthur, this should be fixed in 0.2.1. Could you check if it's fixed?

P.S. The read_html table caches data for 60s. If you're often refreshing localhost:8000, that might be an issue. You can disable caching by adding cache_ttl='0' to the table arguments.

@marcoarthur
Copy link
Author

Sorry the delay @julien040 , but I tested with 0.2.1 and indeed is fixed, thnks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants