Skip to content

chore(examples): implement display_name in the temperature extension type example - #27942

Open
tschwarzinger wants to merge 3 commits into
apache:mainfrom
tschwarzinger:temp-example
Open

tschwarzinger wants to merge 3 commits into
apache:mainfrom
tschwarzinger:temp-example

Conversation

@tschwarzinger

@tschwarzinger tschwarzinger commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

None, just a small addition to an example.

Rationale for this change

While reviewing #26822 I saw that #26866 has been closed which I found great! 🥳

This PR adds the feature from #26866 to the temperature extension type example. For now, I've only added it to the tests. I can also add the describe query to the example's "main" if you think it helps.

What changes are included in this PR?

  • Implement DFExtensionType::display_name for TemperatureExtensionType

What is the testing strategy for this PR?

  • Test the DESCRIBE

https://github.com/tschwarzinger/datafusion/actions/runs/46833480641

Manual Run:

tschwarzinger@pop-os /m/d/b/d/datafusion-examples (temp-example) [1]> cargo run --example extension_types -- all
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.20s
     Running `/mnt/data/bartgeier/datafusion/target/debug/examples/extension_types all`
Running example: temperature
+-------------+-------------+-------------+
| column_name | data_type   | is_nullable |
+-------------+-------------+-------------+
| city        | Utf8        | NO          |
| celsius     | TEMPERATURE | NO          |
| fahrenheit  | TEMPERATURE | NO          |
| kelvin      | TEMPERATURE | NO          |
+-------------+-------------+-------------+
+----------+----------+------------+----------+
| city     | celsius  | fahrenheit | kelvin   |
+----------+----------+------------+----------+
| Vienna   | 15.10 °C | 59.18 °F   | 288.25 K |
| Tokyo    | 22.50 °C | 72.50 °F   | 295.65 K |
| New York | 18.98 °C | 66.16 °F   | 292.13 K |
| Sydney   | 25.00 °C | 77.00 °F   | 298.15 K |
+----------+----------+------------+----------+

Are there any user-facing changes?

  • No, just an example update

}

fn display_name(&self) -> Option<Cow<'_, str>> {
Some(Cow::Borrowed("TEMPERATURE"))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could also print CELSIUS / FAHRENHEIT / KELVIN here if you think that's better

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TEMPERATURE(°C) wouldn't hurt, but it's just an example 😁

@tschwarzinger

Copy link
Copy Markdown
Contributor Author

Maybe you've got an opinion on that because you proposed / implemented the feature @sdf-jkl @cblp

register_temperature_table(&ctx).await?;

// Print the schema of the example table
ctx.sql("DESCRIBE example").await?.show().await?;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Running this in the demo is optional I think. The test is still a good idea I believe.

@cblp cblp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I totally approve

@sdf-jkl sdf-jkl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

}

fn display_name(&self) -> Option<Cow<'_, str>> {
Some(Cow::Borrowed("TEMPERATURE"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TEMPERATURE(°C) wouldn't hurt, but it's just an example 😁

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.

3 participants