Skip to content

Conversation

@samuelcolvin
Copy link
Contributor

@samuelcolvin samuelcolvin commented Sep 11, 2024

Which issue does this PR close?

Closes #12424

Rationale for this change

Pretty self explanatory — it's use to know what version of a database you're using.

What changes are included in this PR?

Adds a version() UDF.

Usage:

cargo run --manifest-path datafusion-cli/Cargo.toml
select version();
+--------------------------------------------+
| version()                                  |
+--------------------------------------------+
| Apache DataFusion 41.0.0, aarch64 on macos |
+--------------------------------------------+
1 row(s) fetched. 
Elapsed 0.018 seconds.

I'd like to add:

  • Rustc version, but that would require a build script or another dependency
  • Arrow-rs version, but would require a new export from arrow-rs, equivalent to datafusion::DATAFUSION_VERSION

Are these changes tested?

yes

Are there any user-facing changes?

Just one new UDF.

@github-actions github-actions bot added the functions Changes to functions implementation label Sep 11, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @samuelcolvin -- this looks very useful.

Can we please also add an entry in the documentation about this function: https://datafusion.apache.org/user-guide/sql/scalar_functions.html#other-functions

It would be nice if we could auto generate this documentation so we don't have to remember to add this type of documentation each time. I will write up a ticket explaining this

@alamb
Copy link
Contributor

alamb commented Sep 11, 2024

It would be nice if we could auto generate this documentation so we don't have to remember to add this type of documentation each time. I will write up a ticket explaining this

I filed #12432 to track this idea

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

I also think we should add a basic test to https://github.com/apache/datafusion/blob/main/datafusion/sqllogictest/test_files/information_schema.slt

(this file has to be updated on every version bump anyways so adding a test there will not increase the release burden)

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Sep 12, 2024
@samuelcolvin
Copy link
Contributor Author

Thank you @samuelcolvin -- this looks very useful.

Can we please also add an entry in the documentation about this function: https://datafusion.apache.org/user-guide/sql/scalar_functions.html#other-functions

It would be nice if we could auto generate this documentation so we don't have to remember to add this type of documentation each time. I will write up a ticket explaining this

done

+--------------------------------------------+
| version() |
+--------------------------------------------+
| Apache DataFusion 41.0.0, aarch64 on macos |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note! this will go out of date very quickly, do we care?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it matters if the doc example doesn't reflect the current version

Copy link
Member

@Weijun-H Weijun-H left a comment

Choose a reason for hiding this comment

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

Very useful feature! Thanks @samuelcolvin 👍

@alamb
Copy link
Contributor

alamb commented Sep 12, 2024

I also think we should add a basic test to https://github.com/apache/datafusion/blob/main/datafusion/sqllogictest/test_files/information_schema.slt

(this file has to be updated on every version bump anyways so adding a test there will not increase the release burden)

Since the function has the architecture in its output too, I don't think there is a way to cover it with tests in slt that wouldn't fail on some platforms. We would have to do it via rust tests where we could #cfg( on the target os.

I think it is ok to merge as is and I will make a PR shortly to add a test.

@alamb
Copy link
Contributor

alamb commented Sep 12, 2024

Thanks again @samuelcolvin and @Weijun-H

@alamb alamb merged commit 5b6b404 into apache:main Sep 12, 2024
@alamb
Copy link
Contributor

alamb commented Sep 12, 2024

Test PR: #12441

@samuelcolvin samuelcolvin deleted the version-udf branch September 19, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a version() function

3 participants