Skip to content

Conversation

@imback82
Copy link
Contributor

@imback82 imback82 commented Oct 2, 2019

What changes were proposed in this pull request?

Currently, SHOW NAMESPACES and SHOW DATABASES are separate code paths. This PR merges two implementations.

Why are the changes needed?

To remove code/behavior duplication

Does this PR introduce any user-facing change?

No

How was this patch tested?

Added new unit tests.

@imback82
Copy link
Contributor Author

imback82 commented Oct 2, 2019

cc: @rdblue / @cloud-fan

@SparkQA
Copy link

SparkQA commented Oct 3, 2019

Test build #111705 has finished for PR 26006 at commit db8968a.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 3, 2019

Test build #111712 has finished for PR 26006 at commit 67114a7.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

retest this please

@SparkQA
Copy link

SparkQA commented Oct 4, 2019

Test build #111771 has finished for PR 26006 at commit 67114a7.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@imback82
Copy link
Contributor Author

imback82 commented Oct 4, 2019

@cloud-fan I merged with #25747 and is ready for review.

throw new AnalysisException(
"SHOW NAMESPACES is not supported with the session catalog.")

// TODO (SPARK-29014): we should check if the current catalog is session catalog here.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can also handle the ShowTables case below as a separate PR (I have tests written up) if you want.

@SparkQA
Copy link

SparkQA commented Oct 4, 2019

Test build #111784 has started for PR 26006 at commit 51966bc.

val CurrentCatalogAndNamespace(catalog, namespace) = nameParts
val ns = if (namespace.isEmpty) { None } else { Some(namespace) }
SetCatalogAndNamespace(catalogManager, Some(catalog.name()), ns)
SetCatalogAndNamespace(catalogManager, Some(catalog.name()), namespace)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will always set the catalog, even if it is already the current? Why not use a rule that doesn't fill in the catalog and returns None instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check is done here:

def setCurrentCatalog(catalogName: String): Unit = synchronized {
// `setCurrentCatalog` is noop if it doesn't switch to a different catalog.
if (currentCatalog.name() != catalogName) {
_currentCatalogName = Some(catalogName)
_currentNamespace = None
// Reset the current database of v1 `SessionCatalog` when switching current catalog, so that
// when we switch back to session catalog, the current namespace definitely is ["default"].
v1SessionCatalog.setCurrentDatabase(SessionCatalog.DEFAULT_DATABASE)
}
}

}

type CurrentCatalogAndNamespace = (CatalogPlugin, Seq[String])
type CurrentCatalogAndNamespace = (CatalogPlugin, Option[Seq[String]])
Copy link
Contributor

Choose a reason for hiding this comment

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

When I see this extractor/type name, it sounds like it should always return the current catalog. What about just naming this CatalogAndNamespace and document that the current catalog may be returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I will update it.

@rdblue
Copy link
Contributor

rdblue commented Oct 4, 2019

Overall looks good to me. The EXPLAIN change is a little concerning and I had some other minor comments.

}

type CurrentCatalogAndNamespace = (CatalogPlugin, Seq[String])
type CatalogAndNamespace = (CatalogPlugin, Option[Seq[String]])
Copy link
Contributor

Choose a reason for hiding this comment

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

This is short, maybe we don't need the type alias.

@cloud-fan
Copy link
Contributor

LGTM except one code style nit. We may need to wait for a few days until Jenkins is back online.

@rdblue
Copy link
Contributor

rdblue commented Oct 10, 2019

+1 from me as well

@cloud-fan
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Oct 14, 2019

Test build #112013 has finished for PR 26006 at commit d8b5362.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan cloud-fan closed this in ef6dce2 Oct 14, 2019
@cloud-fan
Copy link
Contributor

thanks, merging to master!

throw new AnalysisException(
"SHOW NAMESPACES is not supported with the session catalog.")

// TODO (SPARK-29014): we should check if the current catalog is session catalog here.
Copy link
Contributor

Choose a reason for hiding this comment

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

@imback82 can you send a PR to fix SPARK-29014? It should be easy now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will work on this. Thanks!

@imback82 imback82 deleted the combine_show branch October 14, 2019 14:54
cloud-fan added a commit that referenced this pull request Feb 5, 2021
…f SHOW DATABASES

### What changes were proposed in this pull request?

This is a followup of #26006

In #26006 , we merged the v1 and v2 SHOW DATABASES/NAMESPACES commands, but we missed a behavior change that the output schema of SHOW DATABASES becomes different.

This PR adds a legacy config to restore the old schema, with a migration guide item to mention this behavior change.

### Why are the changes needed?

Improve backward compatibility

### Does this PR introduce _any_ user-facing change?

No (the legacy config is false by default)

### How was this patch tested?

a new test

Closes #31474 from cloud-fan/command-schema.

Lead-authored-by: Wenchen Fan <cloud0fan@gmail.com>
Co-authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan added a commit to cloud-fan/spark that referenced this pull request Feb 5, 2021
…f SHOW DATABASES

This is a followup of apache#26006

In apache#26006 , we merged the v1 and v2 SHOW DATABASES/NAMESPACES commands, but we missed a behavior change that the output schema of SHOW DATABASES becomes different.

This PR adds a legacy config to restore the old schema, with a migration guide item to mention this behavior change.

Improve backward compatibility

No (the legacy config is false by default)

a new test

Closes apache#31474 from cloud-fan/command-schema.

Lead-authored-by: Wenchen Fan <cloud0fan@gmail.com>
Co-authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan added a commit that referenced this pull request Feb 5, 2021
…ema of SHOW DATABASES

This backports #31474 to 3.1/3.0

### What changes were proposed in this pull request?

This is a followup of #26006

In #26006 , we merged the v1 and v2 SHOW DATABASES/NAMESPACES commands, but we missed a behavior change that the output schema of SHOW DATABASES becomes different.

This PR adds a legacy config to restore the old schema, with a migration guide item to mention this behavior change.

### Why are the changes needed?

Improve backward compatibility

### Does this PR introduce _any_ user-facing change?

No (the legacy config is false by default)

### How was this patch tested?

a new test

Closes #31486 from cloud-fan/command-schema.

Authored-by: Wenchen Fan <cloud0fan@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan added a commit that referenced this pull request Feb 5, 2021
…ema of SHOW DATABASES

This backports #31474 to 3.1/3.0

This is a followup of #26006

In #26006 , we merged the v1 and v2 SHOW DATABASES/NAMESPACES commands, but we missed a behavior change that the output schema of SHOW DATABASES becomes different.

This PR adds a legacy config to restore the old schema, with a migration guide item to mention this behavior change.

Improve backward compatibility

No (the legacy config is false by default)

a new test

Closes #31486 from cloud-fan/command-schema.

Authored-by: Wenchen Fan <cloud0fan@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit 7c87b48)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants