@@ -101,47 +101,39 @@ class SQLViewSuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
101101 }
102102
103103 test(" correctly parse CREATE TEMPORARY VIEW statement" ) {
104- withSQLConf(SQLConf .NATIVE_VIEW .key -> " true" ) {
105- withView(" testView" ) {
106- sql(
107- """ CREATE TEMPORARY VIEW IF NOT EXISTS
108- |testView (c1 COMMENT 'blabla', c2 COMMENT 'blabla')
109- |TBLPROPERTIES ('a' = 'b')
110- |AS SELECT * FROM jt""" .stripMargin)
111- checkAnswer(sql(" SELECT c1, c2 FROM testView ORDER BY c1" ), (1 to 9 ).map(i => Row (i, i)))
112- }
104+ withView(" testView" ) {
105+ sql(
106+ """ CREATE TEMPORARY VIEW IF NOT EXISTS
107+ |testView (c1 COMMENT 'blabla', c2 COMMENT 'blabla')
108+ |TBLPROPERTIES ('a' = 'b')
109+ |AS SELECT * FROM jt""" .stripMargin)
110+ checkAnswer(sql(" SELECT c1, c2 FROM testView ORDER BY c1" ), (1 to 9 ).map(i => Row (i, i)))
113111 }
114112 }
115113
116114 test(" should NOT allow CREATE TEMPORARY VIEW when TEMPORARY VIEW with same name exists" ) {
117- withSQLConf(SQLConf .NATIVE_VIEW .key -> " true" ) {
118- withView(" testView" ) {
119- sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" )
115+ withView(" testView" ) {
116+ sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" )
120117
121- val e = intercept[AnalysisException ] {
122- sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" ).collect()
123- }
124-
125- assert(e.message.contains(" Temporary view" ) && e.message.contains(" already exists" ))
118+ val e = intercept[AnalysisException ] {
119+ sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" ).collect()
126120 }
121+
122+ assert(e.message.contains(" Temporary view" ) && e.message.contains(" already exists" ))
127123 }
128124 }
129125
130126 test(" should allow CREATE TEMPORARY VIEW when a permanent VIEW with same name exists" ) {
131- withSQLConf(SQLConf .NATIVE_VIEW .key -> " true" ) {
132- withView(" testView" , " default.testView" ) {
133- sql(" CREATE VIEW testView AS SELECT id FROM jt" )
134- sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" ).collect()
135- }
127+ withView(" testView" , " default.testView" ) {
128+ sql(" CREATE VIEW testView AS SELECT id FROM jt" )
129+ sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" ).collect()
136130 }
137131 }
138132
139133 test(" should allow CREATE permanent VIEW when a TEMPORARY VIEW with same name exists" ) {
140- withSQLConf(SQLConf .NATIVE_VIEW .key -> " true" ) {
141- withView(" testView" , " default.testView" ) {
142- sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" )
143- sql(" CREATE VIEW testView AS SELECT id FROM jt" ).collect()
144- }
134+ withView(" testView" , " default.testView" ) {
135+ sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" )
136+ sql(" CREATE VIEW testView AS SELECT id FROM jt" ).collect()
145137 }
146138 }
147139
@@ -163,42 +155,38 @@ class SQLViewSuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
163155 }
164156
165157 test(" correctly handle CREATE TEMPORARY VIEW IF NOT EXISTS" ) {
166- withSQLConf(SQLConf .NATIVE_VIEW .key -> " true" ) {
167- withTable(" jt2" ) {
168- withView(" testView" ) {
169- sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" )
158+ withTable(" jt2" ) {
159+ withView(" testView" ) {
160+ sql(" CREATE TEMPORARY VIEW testView AS SELECT id FROM jt" )
170161
171- val df = (1 until 10 ).map(i => i -> i).toDF(" i" , " j" )
172- df.write.format(" json" ).saveAsTable(" jt2" )
173- sql(" CREATE TEMPORARY VIEW IF NOT EXISTS testView AS SELECT * FROM jt2" )
162+ val df = (1 until 10 ).map(i => i -> i).toDF(" i" , " j" )
163+ df.write.format(" json" ).saveAsTable(" jt2" )
164+ sql(" CREATE TEMPORARY VIEW IF NOT EXISTS testView AS SELECT * FROM jt2" )
174165
175- // make sure our view doesn't change.
176- checkAnswer(sql(" SELECT * FROM testView ORDER BY id" ), (1 to 9 ).map(i => Row (i)))
177- }
166+ // make sure our view doesn't change.
167+ checkAnswer(sql(" SELECT * FROM testView ORDER BY id" ), (1 to 9 ).map(i => Row (i)))
178168 }
179169 }
180170 }
181171
182172 test(s " correctly handle CREATE OR REPLACE TEMPORARY VIEW " ) {
183- withSQLConf(SQLConf .NATIVE_VIEW .key -> " true" ) {
184- withTable(" jt2" ) {
185- withView(" testView" ) {
186- sql(" CREATE OR REPLACE TEMPORARY VIEW testView AS SELECT id FROM jt" )
187- checkAnswer(sql(" SELECT * FROM testView ORDER BY id" ), (1 to 9 ).map(i => Row (i)))
173+ withTable(" jt2" ) {
174+ withView(" testView" ) {
175+ sql(" CREATE OR REPLACE TEMPORARY VIEW testView AS SELECT id FROM jt" )
176+ checkAnswer(sql(" SELECT * FROM testView ORDER BY id" ), (1 to 9 ).map(i => Row (i)))
188177
189- val df = (1 until 10 ).map(i => i -> i).toDF(" i" , " j" )
190- df.write.format(" json" ).saveAsTable(" jt2" )
191- sql(" CREATE OR REPLACE TEMPORARY VIEW testView AS SELECT * FROM jt2" )
192- // make sure the view has been changed.
193- checkAnswer(sql(" SELECT * FROM testView ORDER BY i" ), (1 to 9 ).map(i => Row (i, i)))
178+ val df = (1 until 10 ).map(i => i -> i).toDF(" i" , " j" )
179+ df.write.format(" json" ).saveAsTable(" jt2" )
180+ sql(" CREATE OR REPLACE TEMPORARY VIEW testView AS SELECT * FROM jt2" )
181+ // make sure the view has been changed.
182+ checkAnswer(sql(" SELECT * FROM testView ORDER BY i" ), (1 to 9 ).map(i => Row (i, i)))
194183
195- sql(" DROP VIEW testView" )
184+ sql(" DROP VIEW testView" )
196185
197- val e = intercept[AnalysisException ] {
198- sql(" CREATE OR REPLACE TEMPORARY VIEW IF NOT EXISTS testView AS SELECT id FROM jt" )
199- }
200- assert(e.message.contains(" not allowed to define a view" ))
186+ val e = intercept[AnalysisException ] {
187+ sql(" CREATE OR REPLACE TEMPORARY VIEW IF NOT EXISTS testView AS SELECT id FROM jt" )
201188 }
189+ assert(e.message.contains(" not allowed to define a view" ))
202190 }
203191 }
204192 }
0 commit comments