-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(cherry picked from commit 0fb1b6f)
- Loading branch information
1 parent
ce8d50b
commit b465052
Showing
8 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
core/src/test/scala/org/apache/spark/sql/ViewTestSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.apache.spark.sql | ||
|
||
class ViewTestSuite extends BaseTiSparkSuite { | ||
private val table = "test_view" | ||
|
||
test("Test View") { | ||
tidbStmt.execute(s"drop table if exists $table") | ||
try { | ||
tidbStmt.execute("drop view if exists v") | ||
} catch { | ||
case _: Exception => cancel | ||
} | ||
|
||
tidbStmt.execute(s"create table $table(qty INT, price INT);") | ||
|
||
tidbStmt.execute(s"INSERT INTO $table VALUES(3, 50);") | ||
tidbStmt.execute(s"CREATE VIEW v AS SELECT qty, price, qty*price AS value FROM $table;") | ||
|
||
refreshConnections() | ||
|
||
judge(s"select * from $table") | ||
intercept[AnalysisException](spark.sql("select * from v")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tikv-client/src/main/java/com/pingcap/tikv/meta/TiUserIdentity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.pingcap.tikv.meta; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.io.Serializable; | ||
|
||
// TiUserIdentity represents username and hostname. | ||
public class TiUserIdentity implements Serializable { | ||
private String username; | ||
private String hostname; | ||
private boolean currentUser; | ||
private String authUsername; | ||
private String authHostname; | ||
|
||
@JsonCreator | ||
public TiUserIdentity( | ||
@JsonProperty("Username") String userName, | ||
@JsonProperty("Hostname") String hostName, | ||
@JsonProperty("CurrentUser") boolean currentUser, | ||
@JsonProperty("AuthUsername") String authUserName, | ||
@JsonProperty("AuthHostname") String authHostName) { | ||
this.authHostname = authHostName; | ||
this.authUsername = authUserName; | ||
this.hostname = hostName; | ||
this.username = userName; | ||
this.currentUser = currentUser; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
tikv-client/src/main/java/com/pingcap/tikv/meta/TiViewInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.pingcap.tikv.meta; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class TiViewInfo implements Serializable { | ||
// ViewAlgorithm is VIEW's SQL AlGORITHM characteristic. | ||
// See https://dev.mysql.com/doc/refman/5.7/en/view-algorithms.html | ||
private final long viewAlgorithm; | ||
private final TiUserIdentity userIdentity; | ||
// ViewSecurity is VIEW's SQL SECURITY characteristic. | ||
// See https://dev.mysql.com/doc/refman/5.7/en/create-view.html | ||
private final long viewSecurity; | ||
private final String viewSelect; | ||
// ViewCheckOption is VIEW's WITH CHECK OPTION clause part. | ||
// See https://dev.mysql.com/doc/refman/5.7/en/view-check-option.html | ||
private final long viewCheckOpt; | ||
private final List<String> viewCols; | ||
|
||
@JsonCreator | ||
public TiViewInfo( | ||
@JsonProperty("view_algorithm") long viewAlgorithm, | ||
@JsonProperty("view_definer") TiUserIdentity userIdentity, | ||
@JsonProperty("view_security") long viewSecurity, | ||
@JsonProperty("view_select") String viewSelect, | ||
@JsonProperty("view_checkoption") long viewCheckOpt, | ||
@JsonProperty("view_cols") List<CIStr> viewCols) { | ||
this.viewAlgorithm = viewAlgorithm; | ||
this.userIdentity = userIdentity; | ||
this.viewSecurity = viewSecurity; | ||
this.viewSelect = viewSelect; | ||
this.viewCheckOpt = viewCheckOpt; | ||
this.viewCols = viewCols.stream().map(CIStr::getO).collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters