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

Added SQL string function documentation and examples #4773

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

sanderson
Copy link
Collaborator

  • Rebased/mergeable

@sanderson sanderson requested a review from alamb March 2, 2023 17:32
@sanderson
Copy link
Collaborator Author

sanderson commented Mar 2, 2023

@alamb I noticed some behavior with some of the string functions that may be a bug. If I need to modify a tag value, I have to explicitly cast the tag column to a string. I know that tags and fields use different arrow types (tags seem to be a key-value pair dictionary), but in the context of InfuxDB, tags are always strings, so casting shouldn't be necessary. For example:

SELECT DISTINCT
  upper(room::STRING)
FROM home

I feel like I should just be able to do the following:

SELECT DISTINCT
  upper(room)
FROM home

Is this something worth filing an issue about? I think this is fairly unique to our implementation of SQL, so if I do create an issue, where should I create it?

@alamb
Copy link
Contributor

alamb commented Mar 2, 2023

Hi @sanderson -- I can reproduce the error you are describing here:

26f7e5a4b7be365b_917b97a92e883afc> select distinct host from cpu;
+---------------------+
| host                |
+---------------------+
| MacBook-Pro-8.local |
+---------------------+

But this fails:

26f7e5a4b7be365b_917b97a92e883afc> select distinct upper(host) from cpu;
Error running remote query: Tonic(Status { code: Internal, message: "Error while planning query: Internal error: The \"upper\" function can only accept strings.. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker", metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Thu, 02 Mar 2023 21:27:29 GMT", "content-length": "0"} }, source: None })
26f7e5a4b7be365b_917b97a92e883afc>

I think this is a bug/limitation in DataFusion that should be fixed upstream. I will file a bug.

@@ -0,0 +1,1114 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like great content. Would you be amenable to figuring out how we could move the content into the DataFusion repo (and maybe have a script to sync it over here or something)? That way we could get more reviewers in the community to help review

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan is to port all of this content over to the DataFusion docs once it's complete. That will likely be sometime next week. Pulling content from upstream will be a bit of a challenge since not all functionality upstream is applicable downstream in InfluxDB, but we may be able to figure something out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alamb
Copy link
Contributor

alamb commented Mar 3, 2023

I think this is a bug/limitation in DataFusion that should be fixed upstream. I will file a bug.

apache/datafusion#5471

@sanderson sanderson deleted the sql-string-functions branch May 11, 2023 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants