Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Aug 18, 2023

Which issue does this PR close?

Closes #7272

Rationale for this change

As @UlfarErl notes in #7272, it is somewhat unclear how to use DataFusion to run SQL that can not modify the catalog.

What changes are included in this PR?

  1. Update docs with examples of how to run SQL that can not modify the catalog.

As I was working on these examples, it became clear that the current API is confusing as well as there is no way to avoid DML (aka Insert / COPY). I filed #7328 to track this

Are these changes tested?

Yes, doc tests

Are there any user-facing changes?

Docs

@github-actions github-actions bot added the core Core DataFusion crate label Aug 18, 2023
/// let df = df.filter(col("a").lt_eq(col("b")))?
/// .aggregate(vec![col("a")], vec![min(col("b"))])?
/// .limit(0, Some(100))?;
/// let results = df.collect();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since the results were not used it turns out the example was missing an await

///
/// If this is not desirable, consider using [`SessionState::create_logical_plan()`] which
/// does not mutate the state based on such statements.
/// For read only SQL, use [`SessionState::create_logical_plan()`] to create a
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the core explanation

@alamb
Copy link
Contributor Author

alamb commented Aug 18, 2023

After coding #7333 up, I think improving the API is the way to go so closing this PR for now

@alamb alamb closed this Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading/invalid documentation on SessionContext::sql and SessionConfig::create_logical_plan

1 participant