Skip to content

Make it easier to create ScalarValue from String and &str #8380

Closed

Description

@alamb

Is your feature request related to a problem or challenge?

Someone reported on Discord: https://discord.com/channels/885562378132000778/1166447479609376850/1179899297483980941

currently when I'm trying to pass a String into ScalarValue::from(), the compiler is telling me that the trait bound ScalarValue: Fromstd::string::String is not satisfied

Let's make it easier for people to get started with DataFusioN!

Describe the solution you'd like

Make it so the following code works

let scalar = ScalarValue::from("foo");
let scalar = ScalarValue::from("foo".to_string());

Describe alternatives you've considered

No response

Additional context

I think this is a good first issue as it is well specified and would be a nice usability improvement

Related PR: #8378 (it would be nice to add an example of creating ScalarValue from a string there too)

Activity

  1. QuenKar commented on Dec 1, 2023

    @QuenKar
    Contributor

    Hi, I want to do this issue

  2. QuenKar commented on Dec 1, 2023

    @QuenKar
    Contributor

    I met some question in scalar.rs. when adding a test case for it, it can't compiled in vscode. It seems to have something to do with parquet.

    error[E0433]: failed to resolve: use of undeclared crate or module `parquet`
       --> datafusion/common/src/file_options/mod.rs:302:9
        |
    302 |     use parquet::{
        |         ^^^^^^^ use of undeclared crate or module `parquet`
    
    error[E0432]: unresolved import `super::parquet_writer`
       --> datafusion/common/src/file_options/mod.rs:316:17
        |
    316 |     use super::{parquet_writer::ParquetWriterOptions, StatementOptions};
        |                 ^^^^^^^^^^^^^^ could not find `parquet_writer` in `super`
    
    error[E0599]: no variant or associated item named `PARQUET` found for enum `file_type::FileType` in the current scope
       --> datafusion/common/src/file_options/file_type.rs:120:35
        |
    45  | pub enum FileType {
        | ----------------- variant or associated item `PARQUET` not found for this enum
    ...
    120 |             ("parquet", FileType::PARQUET),
        |                                   ^^^^^^^ variant or associated item not found in `FileType`
    
    error[E0599]: no variant or associated item named `PARQUET` found for enum `file_type::FileType` in the current scope
       --> datafusion/common/src/file_options/file_type.rs:121:35
        |
    45  | pub enum FileType {
        | ----------------- variant or associated item `PARQUET` not found for this enum
    ...
    121 |             ("PARQUET", FileType::PARQUET),
        |                                   ^^^^^^^ variant or associated item not found in `FileType`
    
    error[E0425]: cannot find function `parquet_test_data` in this scope
       --> datafusion/common/src/test_util.rs:292:19
        |
    161 | pub fn arrow_test_data() -> String {
        | ---------------------------------- similarly named function `arrow_test_data` defined here
    ...
    292 |         let res = parquet_test_data();
        |                   ^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `arrow_test_data`
    
    Some errors have detailed explanations: E0425, E0432, E0433, E0599.
    For more information about an error, try `rustc --explain E0425`.
    error: could not compile `datafusion-common` (lib test) due to 5 previous errors
    
  3. alamb commented on Dec 1, 2023

    @alamb
    ContributorAuthor

    I met some question in scalar.rs. when adding a test case for it, it can't compiled in vscode. It seems to have something to do with parquet.

    THanks @QuenKar -- I think this is #8250 (also noticed by @jayzhan211 )

    Here is the workaround: #8250 (comment)

    It would be great for someone to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions