Skip to content

[datafusion-spark] Example of using Spark compatible function library #15915

Closed

Description

@alamb

Is your feature request related to a problem or challenge?

@shehabgamin added the datafusion-spark crate in #15168

The idea is that using the functions in this crate you can get a SessionContext that executes sql using Spark semantics. However, there is no user facing documentation that shows how to do this

Describe the solution you'd like

Add an example somewhere showing how to configure and use the spark functions in a SessionContext. I can help with this

Describe alternatives you've considered

I personally suggest adding a new page to the website: https://datafusion.apache.org/

Specifically, I suggest

  1. Add a new page in the "Library User Guide" called "Spark Compatible Functions"
  2. Add a preamble explaining what the datafusion-spark crate is (contains a list of spark compatible functions)
  3. Add examples

For example we should show how to run sql using a "spark compatible" frame:

let ctx = SessionContext::new();
datafusion_spark::register_all(&ctx)?;

// TODO run an example SQL query here that uses a function from 
// the datafusion spark crate
ctx.sql("select ... ")

// also add an example for DataFrame API

In order to run the example code as part of CI, you will have to add an entry such as this:

#[cfg(doctest)]
doc_comment::doctest!(
"../../../docs/source/user-guide/introduction.md",
user_guide_introduction
);

to the datafusion-spark lib.rs file (it can't go in the datafusion/core/lib.rs because the core crate doesn't bring in datafusion-spark)

Additional context

No response

Activity

  1. alamb commented on May 2, 2025

    @alamb
    ContributorAuthor

    I think this is a good first issue as there is a clear request of what is desired and examples to follow

  2. Adez017 commented on May 2, 2025

    @Adez017
    Contributor

    hi @alamb . it sounds interesting , i would love to work in this .

  3. Adez017 commented on May 2, 2025

    @Adez017
    Contributor

    take

  4. alamb commented on May 2, 2025

    @alamb
    ContributorAuthor

    Thanks @Adez017

  5. self-assigned this
    on Jun 11, 2025
  6. alamb commented on Jun 12, 2025

    @alamb
    ContributorAuthor

    I made a PR for this issue -- it was a bit trickier than I expected

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

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions