@@ -134,26 +134,26 @@ public class ViewUtil {
134
134
public static Pair <List <PTable >, List <TableInfo >> findAllDescendantViews (
135
135
Table sysCatOrsysChildLink , Configuration serverSideConfig , byte [] tenantId ,
136
136
byte [] schemaName , byte [] tableOrViewName , long clientTimeStamp ,
137
- boolean findJustOneLegitimateChildView )
137
+ boolean findJustOneLegitimateChildView , boolean isServerConnection )
138
138
throws IOException , SQLException {
139
139
List <PTable > legitimateChildViews = new ArrayList <>();
140
140
List <TableInfo > orphanChildViews = new ArrayList <>();
141
141
142
142
return findAllDescendantViews (sysCatOrsysChildLink , serverSideConfig , tenantId , schemaName ,
143
143
tableOrViewName , clientTimeStamp , legitimateChildViews , orphanChildViews ,
144
- findJustOneLegitimateChildView );
144
+ findJustOneLegitimateChildView , isServerConnection );
145
145
}
146
146
147
147
public static Pair <List <PTable >, List <TableInfo >> findAllDescendantViews (Table sysCatOrsysChildLink ,
148
148
Configuration serverSideConfig , byte [] parentTenantId , byte [] parentSchemaName ,
149
149
byte [] parentTableOrViewName , long clientTimeStamp , List <PTable > legitimateChildViews ,
150
- List <TableInfo > orphanChildViews , boolean findJustOneLegitimateChildView )
150
+ List <TableInfo > orphanChildViews , boolean findJustOneLegitimateChildView , boolean isServerConnection )
151
151
throws IOException , SQLException {
152
152
153
153
return findAllDescendantViews (sysCatOrsysChildLink , null , serverSideConfig ,
154
154
parentTenantId , parentSchemaName , parentTableOrViewName , clientTimeStamp ,
155
155
legitimateChildViews , orphanChildViews , findJustOneLegitimateChildView ,
156
- new Pair <>(false , false ));
156
+ new Pair <>(false , false ), isServerConnection );
157
157
158
158
}
159
159
@@ -208,7 +208,7 @@ public static Pair<List<PTable>, List<TableInfo>> findAllDescendantViews(
208
208
byte [] parentTenantId , byte [] parentSchemaName , byte [] parentTableOrViewName ,
209
209
long clientTimeStamp , List <PTable > legitimateChildViews ,
210
210
List <TableInfo > orphanChildViews , boolean findJustOneLegitimateChildView ,
211
- Pair <Boolean , Boolean > scanSysCatForTTLDefinedOnAnyChildPair )
211
+ Pair <Boolean , Boolean > scanSysCatForTTLDefinedOnAnyChildPair , boolean isServerConnection )
212
212
throws IOException , SQLException {
213
213
TableViewFinderResult currentResult =
214
214
findImmediateRelatedViews (sysCatOrsysChildLink , sysCat , parentTenantId ,
@@ -226,9 +226,11 @@ public static Pair<List<PTable>, List<TableInfo>> findAllDescendantViews(
226
226
if (clientTimeStamp != HConstants .LATEST_TIMESTAMP ) {
227
227
props .setProperty (CURRENT_SCN_ATTRIB , Long .toString (clientTimeStamp ));
228
228
}
229
- try (PhoenixConnection connection =
230
- QueryUtil .getConnectionOnServer (props , serverSideConfig )
231
- .unwrap (PhoenixConnection .class )) {
229
+ try (PhoenixConnection connection = ((isServerConnection ) ?
230
+ QueryUtil .getConnectionOnServer (props , serverSideConfig )
231
+ .unwrap (PhoenixConnection .class ) :
232
+ QueryUtil .getConnection (props , serverSideConfig )
233
+ .unwrap (PhoenixConnection .class ))){
232
234
try {
233
235
view = connection .getTableNoCache (
234
236
SchemaUtil .getTableName (viewSchemaName , viewName ));
@@ -257,7 +259,7 @@ public static Pair<List<PTable>, List<TableInfo>> findAllDescendantViews(
257
259
viewInfo .getTenantId (), viewInfo .getSchemaName (),
258
260
viewInfo .getTableName (), clientTimeStamp , legitimateChildViews ,
259
261
orphanChildViews , findJustOneLegitimateChildView ,
260
- scanSysCatForTTLDefinedOnAnyChildPair );
262
+ scanSysCatForTTLDefinedOnAnyChildPair , isServerConnection );
261
263
} else {
262
264
logger .error ("Found an orphan parent->child link keyed by this parent."
263
265
+ " Parent Tenant Id: '" + Bytes .toString (parentTenantId )
@@ -285,7 +287,7 @@ private static boolean isLegitimateChildView(PTable view, byte[] parentSchemaNam
285
287
* Returns relatives in a breadth-first fashion. Note that this is not resilient to orphan
286
288
* linking rows and we also do not try to resolve any of the views to ensure they are valid.
287
289
* Use {@link ViewUtil#findAllDescendantViews(Table, Configuration, byte[], byte[], byte[],
288
- * long, boolean)} if you are only interested in {@link LinkType#CHILD_TABLE} and need to be
290
+ * long, boolean, boolean )} if you are only interested in {@link LinkType#CHILD_TABLE} and need to be
289
291
* resilient to orphan linking rows.
290
292
*
291
293
* @param sysCatOrsysChildLink Table corresponding to either SYSTEM.CATALOG or SYSTEM.CHILD_LINK
0 commit comments