Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CatalogTableType constructor access modifier renders useless when case class factory is public #17040

Closed
wants to merge 1 commit into from
Closed

CatalogTableType constructor access modifier renders useless when case class factory is public #17040

wants to merge 1 commit into from

Conversation

pfcoperez
Copy link

@pfcoperez pfcoperez commented Feb 23, 2017

What changes were proposed in this pull request?

CatalogTableType seems to implement an union data type enumerating all possible catalog table types.

It is built using a case class with a single value attribute "name". Wisely, it seems to be intended to be set only by the case class private constructor within the companion object with the idea of users not being able to create CatalogTableType instances but using those enumerated within that object.

However, making the case class constructor private does't forbid users creating whichever instances they want to create since the case class factory is still public. e.g:

scala> case class C private(x: Int)
defined class C

scala> C(1)
res0: C = C(1) // Should users be able to do this?

scala> new C(1) //This is the expected behaviour.
<console>:13: error: constructor C in class C cannot be accessed in object $iw
       new C(1)

This PR makes CatalogTableType a regular class, if matching the name was necessary, its companion object could implement unapply. Alternatives ways of solving this could be just using Scala's enumeration or model CatalogTableType using algebraic data types based on extending an interface, e.g:

trait CatalogTableType { val name: String } 

object CatalogTableType {
  object EXTERNAL extends CatalogTableType { val name = "EXTERNAL" }
  object INTERNAL extends CatalogTableType { val name = "INTERNAL" }
  object VIEW     extends CatalogTableType { val name = "VIEW" }
}

How was this patch tested?

This PR does not add new functionality and has thus been tested by your current test suite.

…ault `apply` factory for the case class remains public so this constraint is useless since anyone can use that factory to create customized instances.
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@HyukjinKwon
Copy link
Member

I guess this is meant to be internal API -

* Catalyst is a library for manipulating relational query plans. All classes in catalyst are
* considered an internal API to Spark SQL and are subject to change between minor releases.

Could you maybe open a JIRA and describe usecase to persuade make this a proper external API maybe?

Also, it'd be great if this PR follows http://spark.apache.org/contributing.html (e.g., [SPARK-XXXX] in the PR title with a JIRA).

@maropu maropu mentioned this pull request Apr 23, 2017
maropu added a commit to maropu/spark that referenced this pull request Apr 23, 2017
@asfgit asfgit closed this in e9f9715 Apr 24, 2017
peter-toth pushed a commit to peter-toth/spark that referenced this pull request Oct 6, 2018
This pr proposed to close stale PRs. Currently, we have 400+ open PRs and there are some stale PRs whose JIRA tickets have been already closed and whose JIRA tickets does not exist (also, they seem not to be minor issues).

// Open PRs whose JIRA tickets have been already closed
Closes apache#11785
Closes apache#13027
Closes apache#13614
Closes apache#13761
Closes apache#15197
Closes apache#14006
Closes apache#12576
Closes apache#15447
Closes apache#13259
Closes apache#15616
Closes apache#14473
Closes apache#16638
Closes apache#16146
Closes apache#17269
Closes apache#17313
Closes apache#17418
Closes apache#17485
Closes apache#17551
Closes apache#17463
Closes apache#17625

// Open PRs whose JIRA tickets does not exist and they are not minor issues
Closes apache#10739
Closes apache#15193
Closes apache#15344
Closes apache#14804
Closes apache#16993
Closes apache#17040
Closes apache#15180
Closes apache#17238

N/A

Author: Takeshi Yamamuro <yamamuro@apache.org>

Closes apache#17734 from maropu/resolved_pr.

Change-Id: Id2e590aa7283fe5ac01424d30a40df06da6098b5
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