Review Board 1.7.22


SQOOP-900 Sqoop2: Introduce human readable coding style for queries stored in DerbySchemaQuery

Review Request #9485 - Created Feb. 17, 2013 and submitted

Jarek Cecho
SQOOP-900
Reviewers
Sqoop
sqoop-sqoop2
I've changed the coding style, so that it's easier (at least for me) to see what the queries are doing. I did not change any query - e.g. generated sql should be always the same. Only the appearance in the source code is different.
Unit tests seems to be passing and I've tested this change on real cluster.
repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
Revision 314948cfa07aac1c9bb8ae4656f7a1c0170a57e3 New Change
[20] 200 lines
[+20]
201
      + COLUMN_SQF_CONNECTOR + " BIGINT, "
201
      + COLUMN_SQF_CONNECTOR + " BIGINT, "
202
      + COLUMN_SQF_OPERATION + " VARCHAR(32), "
202
      + COLUMN_SQF_OPERATION + " VARCHAR(32), "
203
      + COLUMN_SQF_NAME + " VARCHAR(64), "
203
      + COLUMN_SQF_NAME + " VARCHAR(64), "
204
      + COLUMN_SQF_TYPE + " VARCHAR(32), "
204
      + COLUMN_SQF_TYPE + " VARCHAR(32), "
205
      + COLUMN_SQF_INDEX + " SMALLINT, "
205
      + COLUMN_SQF_INDEX + " SMALLINT, "
206
      + " FOREIGN KEY (" + COLUMN_SQF_CONNECTOR+ ") REFERENCES " + TABLE_SQ_CONNECTOR + " (" + COLUMN_SQC_ID + ")"
206
      + " FOREIGN KEY (" + COLUMN_SQF_CONNECTOR+ ")"

    
   
207
        + " REFERENCES " + TABLE_SQ_CONNECTOR + " (" + COLUMN_SQC_ID + ")"
207
      + ")";
208
      + ")";
208

    
   
209

   
209
  // DDL: Create table SQ_INPUT
210
  // DDL: Create table SQ_INPUT
210
  public static final String QUERY_CREATE_TABLE_SQ_INPUT =
211
  public static final String QUERY_CREATE_TABLE_SQ_INPUT =
211
      "CREATE TABLE " + TABLE_SQ_INPUT + " ("
212
      "CREATE TABLE " + TABLE_SQ_INPUT + " ("
212
      + COLUMN_SQI_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
213
      + COLUMN_SQI_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
213
      + COLUMN_SQI_NAME + " VARCHAR(64), "
214
      + COLUMN_SQI_NAME + " VARCHAR(64), "
214
      + COLUMN_SQI_FORM + " BIGINT, "
215
      + COLUMN_SQI_FORM + " BIGINT, "
215
      + COLUMN_SQI_INDEX + " SMALLINT, "
216
      + COLUMN_SQI_INDEX + " SMALLINT, "
216
      + COLUMN_SQI_TYPE + " VARCHAR(32), "
217
      + COLUMN_SQI_TYPE + " VARCHAR(32), "
217
      + COLUMN_SQI_STRMASK + " BOOLEAN, "
218
      + COLUMN_SQI_STRMASK + " BOOLEAN, "
218
      + COLUMN_SQI_STRLENGTH + " SMALLINT, "
219
      + COLUMN_SQI_STRLENGTH + " SMALLINT, "
219
      + COLUMN_SQI_ENUMVALS + " VARCHAR(100),"
220
      + COLUMN_SQI_ENUMVALS + " VARCHAR(100),"
220
      + " FOREIGN KEY (" + COLUMN_SQI_FORM + ") REFERENCES " + TABLE_SQ_FORM + " (" + COLUMN_SQF_ID + ")"
221
      + " FOREIGN KEY (" + COLUMN_SQI_FORM + ")"

    
   
222
        + " REFERENCES " + TABLE_SQ_FORM + " (" + COLUMN_SQF_ID + ")"
221
      + ")";
223
      + ")";
222

    
   
224

   
223
  // DDL: Create table SQ_CONNECTION
225
  // DDL: Create table SQ_CONNECTION
224
  public static final String QUERY_CREATE_TABLE_SQ_CONNECTION =
226
  public static final String QUERY_CREATE_TABLE_SQ_CONNECTION =
225
      "CREATE TABLE " + TABLE_SQ_CONNECTION + " ("
227
      "CREATE TABLE " + TABLE_SQ_CONNECTION + " ("
226
      + COLUMN_SQN_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
228
      + COLUMN_SQN_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
227
      + COLUMN_SQN_CONNECTOR + " BIGINT, "
229
      + COLUMN_SQN_CONNECTOR + " BIGINT, "
228
      + COLUMN_SQN_NAME  + " VARCHAR(32),"
230
      + COLUMN_SQN_NAME  + " VARCHAR(32),"
229
      + COLUMN_SQN_CREATION_DATE + " TIMESTAMP,"
231
      + COLUMN_SQN_CREATION_DATE + " TIMESTAMP,"
230
      + COLUMN_SQN_UPDATE_DATE + " TIMESTAMP,"
232
      + COLUMN_SQN_UPDATE_DATE + " TIMESTAMP,"
231
      + " FOREIGN KEY(" + COLUMN_SQN_CONNECTOR + ") REFERENCES " + TABLE_SQ_CONNECTOR + " (" + COLUMN_SQC_ID + ")"
233
      + " FOREIGN KEY(" + COLUMN_SQN_CONNECTOR + ")"

    
   
234
        + " REFERENCES " + TABLE_SQ_CONNECTOR + " (" + COLUMN_SQC_ID + ")"
232
      + ")";
235
      + ")";
233

    
   
236

   
234
  // DDL: Create table SQ_JOB
237
  // DDL: Create table SQ_JOB
235
  public static final String QUERY_CREATE_TABLE_SQ_JOB =
238
  public static final String QUERY_CREATE_TABLE_SQ_JOB =
236
      "CREATE TABLE " + TABLE_SQ_JOB + " ("
239
      "CREATE TABLE " + TABLE_SQ_JOB + " ("
237
      + COLUMN_SQB_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
240
      + COLUMN_SQB_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
238
      + COLUMN_SQB_CONNECTION + " BIGINT, "
241
      + COLUMN_SQB_CONNECTION + " BIGINT, "
239
      + COLUMN_SQB_NAME + " VARCHAR(64), "
242
      + COLUMN_SQB_NAME + " VARCHAR(64), "
240
      + COLUMN_SQB_TYPE + " VARCHAR(64),"
243
      + COLUMN_SQB_TYPE + " VARCHAR(64),"
241
      + COLUMN_SQB_CREATION_DATE + " TIMESTAMP,"
244
      + COLUMN_SQB_CREATION_DATE + " TIMESTAMP,"
242
      + COLUMN_SQB_UPDATE_DATE + " TIMESTAMP,"
245
      + COLUMN_SQB_UPDATE_DATE + " TIMESTAMP,"
243
      + " FOREIGN KEY(" + COLUMN_SQB_CONNECTION + ") REFERENCES " + TABLE_SQ_CONNECTION + " (" + COLUMN_SQN_ID + ")"
246
      + " FOREIGN KEY(" + COLUMN_SQB_CONNECTION + ")"

    
   
247
        + " REFERENCES " + TABLE_SQ_CONNECTION + " (" + COLUMN_SQN_ID + ")"
244
      + ")";
248
      + ")";
245

    
   
249

   
246
  // DDL: Create table SQ_CONNECTION_INPUT
250
  // DDL: Create table SQ_CONNECTION_INPUT
247
  public static final String QUERY_CREATE_TABLE_SQ_CONNECTION_INPUT =
251
  public static final String QUERY_CREATE_TABLE_SQ_CONNECTION_INPUT =
248
      "CREATE TABLE " + TABLE_SQ_CONNECTION_INPUT + " ("
252
      "CREATE TABLE " + TABLE_SQ_CONNECTION_INPUT + " ("
249
      + COLUMN_SQNI_CONNECTION + " BIGINT, "
253
      + COLUMN_SQNI_CONNECTION + " BIGINT, "
250
      + COLUMN_SQNI_INPUT + " BIGINT, "
254
      + COLUMN_SQNI_INPUT + " BIGINT, "
251
      + COLUMN_SQNI_VALUE + " LONG VARCHAR,"
255
      + COLUMN_SQNI_VALUE + " LONG VARCHAR,"
252
      + " PRIMARY KEY (" + COLUMN_SQNI_CONNECTION + ", " + COLUMN_SQNI_INPUT + "),"
256
      + " PRIMARY KEY (" + COLUMN_SQNI_CONNECTION + ", " + COLUMN_SQNI_INPUT + "),"
253
      + " FOREIGN KEY (" + COLUMN_SQNI_CONNECTION + ") REFERENCES " + TABLE_SQ_CONNECTION + " (" + COLUMN_SQN_ID + "),"
257
      + " FOREIGN KEY (" + COLUMN_SQNI_CONNECTION + ")"
254
      + " FOREIGN KEY (" + COLUMN_SQNI_INPUT + ") REFERENCES " + TABLE_SQ_INPUT + " (" + COLUMN_SQI_ID + ")"
258
        + " REFERENCES " + TABLE_SQ_CONNECTION + " (" + COLUMN_SQN_ID + "),"

    
   
259
      + " FOREIGN KEY (" + COLUMN_SQNI_INPUT + ")"

    
   
260
        + " REFERENCES " + TABLE_SQ_INPUT + " (" + COLUMN_SQI_ID + ")"
255
      + ")";
261
      + ")";
256

    
   
262

   
257
  // DDL: Create table SQ_JOB_INPUT
263
  // DDL: Create table SQ_JOB_INPUT
258
  public static final String QUERY_CREATE_TABLE_SQ_JOB_INPUT =
264
  public static final String QUERY_CREATE_TABLE_SQ_JOB_INPUT =
259
      "CREATE TABLE " + TABLE_SQ_JOB_INPUT + " ("
265
      "CREATE TABLE " + TABLE_SQ_JOB_INPUT + " ("
260
      + COLUMN_SQBI_JOB + " BIGINT, "
266
      + COLUMN_SQBI_JOB + " BIGINT, "
261
      + COLUMN_SQBI_INPUT + " BIGINT, "
267
      + COLUMN_SQBI_INPUT + " BIGINT, "
262
      + COLUMN_SQBI_VALUE + " LONG VARCHAR,"
268
      + COLUMN_SQBI_VALUE + " LONG VARCHAR,"
263
      + " PRIMARY KEY (" + COLUMN_SQBI_JOB + ", " + COLUMN_SQBI_INPUT + "), "
269
      + " PRIMARY KEY (" + COLUMN_SQBI_JOB + ", " + COLUMN_SQBI_INPUT + "), "
264
      + " FOREIGN KEY (" + COLUMN_SQBI_JOB + ") REFERENCES " + TABLE_SQ_JOB + " (" + COLUMN_SQB_ID + "), "
270
      + " FOREIGN KEY (" + COLUMN_SQBI_JOB + ")"
265
      + " FOREIGN KEY (" + COLUMN_SQBI_INPUT + ") REFERENCES " + TABLE_SQ_INPUT + " (" + COLUMN_SQI_ID + "))";
271
        + " REFERENCES " + TABLE_SQ_JOB + " (" + COLUMN_SQB_ID + "), "

    
   
272
      + " FOREIGN KEY (" + COLUMN_SQBI_INPUT + ")"

    
   
273
        + " REFERENCES " + TABLE_SQ_INPUT + " (" + COLUMN_SQI_ID + ")"

    
   
274
      + ")";
266

    
   
275

   
267
  // DDL: Create table SQ_SUBMISSION
276
  // DDL: Create table SQ_SUBMISSION
268
  public static final String QUERY_CREATE_TABLE_SQ_SUBMISSION =
277
  public static final String QUERY_CREATE_TABLE_SQ_SUBMISSION =
269
    "CREATE TABLE " + TABLE_SQ_SUBMISSION + " ("
278
    "CREATE TABLE " + TABLE_SQ_SUBMISSION + " ("
270
    + COLUMN_SQS_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), "
279
    + COLUMN_SQS_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), "
[+20] [20] 4 lines
[+20]
275
    + COLUMN_SQS_EXTERNAL_ID + " VARCHAR(25), "
284
    + COLUMN_SQS_EXTERNAL_ID + " VARCHAR(25), "
276
    + COLUMN_SQS_EXTERNAL_LINK + " VARCHAR(150), "
285
    + COLUMN_SQS_EXTERNAL_LINK + " VARCHAR(150), "
277
    + COLUMN_SQS_EXCEPTION + " VARCHAR(150), "
286
    + COLUMN_SQS_EXCEPTION + " VARCHAR(150), "
278
    + COLUMN_SQS_EXCEPTION_TRACE + " VARCHAR(750), "
287
    + COLUMN_SQS_EXCEPTION_TRACE + " VARCHAR(750), "
279
    + "PRIMARY KEY (" + COLUMN_SQS_ID + "), "
288
    + "PRIMARY KEY (" + COLUMN_SQS_ID + "), "
280
    + "FOREIGN KEY (" + COLUMN_SQS_JOB + ") REFERENCES " + TABLE_SQ_JOB + "("  + COLUMN_SQB_ID + ") ON DELETE CASCADE"
289
    + "FOREIGN KEY (" + COLUMN_SQS_JOB + ")"

    
   
290
      + " REFERENCES " + TABLE_SQ_JOB + "("  + COLUMN_SQB_ID + ") ON DELETE CASCADE"
281
    +  ")";
291
    +  ")";
282

    
   
292

   
283
  // DDL: Create table SQ_COUNTER_GROUP
293
  // DDL: Create table SQ_COUNTER_GROUP
284
  public static final String QUERY_CREATE_TABLE_SQ_COUNTER_GROUP =
294
  public static final String QUERY_CREATE_TABLE_SQ_COUNTER_GROUP =
285
    "CREATE TABLE " + TABLE_SQ_COUNTER_GROUP + " ("
295
    "CREATE TABLE " + TABLE_SQ_COUNTER_GROUP + " ("
[+20] [20] 18 lines
[+20]
304
    + COLUMN_SQRS_GROUP + " BIGINT, "
314
    + COLUMN_SQRS_GROUP + " BIGINT, "
305
    + COLUMN_SQRS_COUNTER + " BIGINT, "
315
    + COLUMN_SQRS_COUNTER + " BIGINT, "
306
    + COLUMN_SQRS_SUBMISSION + " BIGINT, "
316
    + COLUMN_SQRS_SUBMISSION + " BIGINT, "
307
    + COLUMN_SQRS_VALUE + " BIGINT, "
317
    + COLUMN_SQRS_VALUE + " BIGINT, "
308
    + "PRIMARY KEY (" + COLUMN_SQRS_GROUP + ", " + COLUMN_SQRS_COUNTER + ", " + COLUMN_SQRS_SUBMISSION + "), "
318
    + "PRIMARY KEY (" + COLUMN_SQRS_GROUP + ", " + COLUMN_SQRS_COUNTER + ", " + COLUMN_SQRS_SUBMISSION + "), "
309
    + "FOREIGN KEY (" + COLUMN_SQRS_GROUP + ") REFERENCES " + TABLE_SQ_COUNTER_GROUP + "(" + COLUMN_SQG_ID + "), "
319
    + "FOREIGN KEY (" + COLUMN_SQRS_GROUP + ")"
310
    + "FOREIGN KEY (" + COLUMN_SQRS_COUNTER + ") REFERENCES " + TABLE_SQ_COUNTER + "(" + COLUMN_SQR_ID + "), "
320
      + " REFERENCES " + TABLE_SQ_COUNTER_GROUP + "(" + COLUMN_SQG_ID + "), "
311
    + "FOREIGN KEY (" + COLUMN_SQRS_SUBMISSION + ") REFERENCES " + TABLE_SQ_SUBMISSION + "(" + COLUMN_SQS_ID + ") ON DELETE CASCADE "
321
    + "FOREIGN KEY (" + COLUMN_SQRS_COUNTER + ")"

    
   
322
      + " REFERENCES " + TABLE_SQ_COUNTER + "(" + COLUMN_SQR_ID + "), "

    
   
323
    + "FOREIGN KEY (" + COLUMN_SQRS_SUBMISSION + ")"

    
   
324
      + " REFERENCES " + TABLE_SQ_SUBMISSION + "(" + COLUMN_SQS_ID + ") ON DELETE CASCADE "
312
    + ")";
325
    + ")";
313

    
   
326

   
314
  // DML: Fetch connector Given Name
327
  // DML: Fetch connector Given Name
315
  public static final String STMT_FETCH_BASE_CONNECTOR =
328
  public static final String STMT_FETCH_BASE_CONNECTOR =
316
      "SELECT "
329
      "SELECT "
[+20] [20] 5 lines
[+20]
322
      + " WHERE " + COLUMN_SQC_NAME + " = ?";
335
      + " WHERE " + COLUMN_SQC_NAME + " = ?";
323

    
   
336

   
324

    
   
337

   
325
  // DML: Fetch all forms for a given connector
338
  // DML: Fetch all forms for a given connector
326
  public static final String STMT_FETCH_FORM_CONNECTOR =
339
  public static final String STMT_FETCH_FORM_CONNECTOR =
327
      "SELECT " + COLUMN_SQF_ID + ", " + COLUMN_SQF_CONNECTOR + ", "
340
      "SELECT "
328
      + COLUMN_SQF_OPERATION + ", " + COLUMN_SQF_NAME + ", " + COLUMN_SQF_TYPE
341
      + COLUMN_SQF_ID + ", "
329
      + ", " + COLUMN_SQF_INDEX + " FROM " + TABLE_SQ_FORM + " WHERE "
342
      + COLUMN_SQF_CONNECTOR + ", "
330
      + COLUMN_SQF_CONNECTOR + " = ? ORDER BY " + COLUMN_SQF_INDEX;
343
      + COLUMN_SQF_OPERATION + ", "

    
   
344
      + COLUMN_SQF_NAME + ", "

    
   
345
      + COLUMN_SQF_TYPE + ", "

    
   
346
      + COLUMN_SQF_INDEX

    
   
347
      + " FROM " + TABLE_SQ_FORM

    
   
348
      + " WHERE " + COLUMN_SQF_CONNECTOR + " = ? "

    
   
349
      + " ORDER BY " + COLUMN_SQF_INDEX;
331

    
   
350

   
332
  // DML: Fetch all framework forms
351
  // DML: Fetch all framework forms
333
  public static final String STMT_FETCH_FORM_FRAMEWORK =
352
  public static final String STMT_FETCH_FORM_FRAMEWORK =
334
      "SELECT " + COLUMN_SQF_ID + ", " + COLUMN_SQF_CONNECTOR + ", "
353
      "SELECT "
335
      + COLUMN_SQF_OPERATION + ", " + COLUMN_SQF_NAME + ", " + COLUMN_SQF_TYPE
354
      + COLUMN_SQF_ID + ", "
336
      + ", " + COLUMN_SQF_INDEX + " FROM " + TABLE_SQ_FORM + " WHERE " +
355
      + COLUMN_SQF_CONNECTOR + ", "
337
      COLUMN_SQF_CONNECTOR + " IS NULL ORDER BY " + COLUMN_SQF_INDEX;
356
      + COLUMN_SQF_OPERATION + ", "

    
   
357
      + COLUMN_SQF_NAME + ", "

    
   
358
      + COLUMN_SQF_TYPE + ", "

    
   
359
      + COLUMN_SQF_INDEX

    
   
360
      + " FROM " + TABLE_SQ_FORM

    
   
361
      + " WHERE " + COLUMN_SQF_CONNECTOR + " IS NULL "

    
   
362
      + " ORDER BY " + COLUMN_SQF_INDEX;
338

    
   
363

   
339
  // DML: Fetch inputs for a given form
364
  // DML: Fetch inputs for a given form
340
  public static final String STMT_FETCH_INPUT =
365
  public static final String STMT_FETCH_INPUT =
341
      "SELECT " + COLUMN_SQI_ID + ", " + COLUMN_SQI_NAME + ", "
366
      "SELECT "
342
      + COLUMN_SQI_FORM + ", " + COLUMN_SQI_INDEX + ", " + COLUMN_SQI_TYPE
367
      + COLUMN_SQI_ID + ", "
343
      + ", " + COLUMN_SQI_STRMASK + ", " + COLUMN_SQI_STRLENGTH + ", "
368
      + COLUMN_SQI_NAME + ", "
344
      + COLUMN_SQI_ENUMVALS + ", cast(null as varchar(100)) FROM "
369
      + COLUMN_SQI_FORM + ", "
345
      + TABLE_SQ_INPUT + " WHERE " + COLUMN_SQI_FORM + " = ? ORDER BY "
370
      + COLUMN_SQI_INDEX + ", "
346
      + COLUMN_SQI_INDEX;
371
      + COLUMN_SQI_TYPE + ", "

    
   
372
      + COLUMN_SQI_STRMASK + ", "

    
   
373
      + COLUMN_SQI_STRLENGTH + ", "

    
   
374
      + COLUMN_SQI_ENUMVALS + ", "

    
   
375
      + "cast(null as varchar(100))"

    
   
376
      + " FROM " + TABLE_SQ_INPUT

    
   
377
      + " WHERE " + COLUMN_SQI_FORM + " = ?"

    
   
378
      + " ORDER BY " + COLUMN_SQI_INDEX;
347

    
   
379

   
348
  // DML: Fetch inputs and values for a given connection
380
  // DML: Fetch inputs and values for a given connection
349
  public static final String STMT_FETCH_CONNECTION_INPUT =
381
  public static final String STMT_FETCH_CONNECTION_INPUT =
350
      "SELECT " + COLUMN_SQI_ID + ", " + COLUMN_SQI_NAME + ", "
382
      "SELECT "
351
      + COLUMN_SQI_FORM + ", " + COLUMN_SQI_INDEX + ", " + COLUMN_SQI_TYPE
383
      + COLUMN_SQI_ID + ", "
352
      + ", " + COLUMN_SQI_STRMASK + ", " + COLUMN_SQI_STRLENGTH + ","
384
      + COLUMN_SQI_NAME + ", "
353
      + COLUMN_SQI_ENUMVALS + ", " + COLUMN_SQNI_VALUE + " FROM "
385
      + COLUMN_SQI_FORM + ", "
354
      + TABLE_SQ_INPUT + " LEFT OUTER JOIN " + TABLE_SQ_CONNECTION_INPUT
386
      + COLUMN_SQI_INDEX + ", "
355
      + " ON " + COLUMN_SQNI_INPUT + " = " + COLUMN_SQI_ID + " AND "
387
      + COLUMN_SQI_TYPE + ", "
356
      + COLUMN_SQNI_CONNECTION + " = ? WHERE " + COLUMN_SQI_FORM + " = ? AND ("
388
      + COLUMN_SQI_STRMASK + ", "
357
      + COLUMN_SQNI_CONNECTION + " = ? OR " + COLUMN_SQNI_CONNECTION
389
      + COLUMN_SQI_STRLENGTH + ","
358
      + " IS NULL) ORDER BY " + COLUMN_SQI_INDEX;
390
      + COLUMN_SQI_ENUMVALS + ", "

    
   
391
      + COLUMN_SQNI_VALUE

    
   
392
      + " FROM " + TABLE_SQ_INPUT

    
   
393
      + " LEFT OUTER JOIN " + TABLE_SQ_CONNECTION_INPUT

    
   
394
        + " ON " + COLUMN_SQNI_INPUT + " = " + COLUMN_SQI_ID

    
   
395
        + " AND " + COLUMN_SQNI_CONNECTION + " = ?"

    
   
396
      + " WHERE " + COLUMN_SQI_FORM + " = ?"

    
   
397
        + " AND (" + COLUMN_SQNI_CONNECTION + " = ?" + " OR " + COLUMN_SQNI_CONNECTION + " IS NULL)"

    
   
398
      + " ORDER BY " + COLUMN_SQI_INDEX;
359

    
   
399

   
360
  // DML: Fetch inputs and values for a given job
400
  // DML: Fetch inputs and values for a given job
361
  public static final String STMT_FETCH_JOB_INPUT =
401
  public static final String STMT_FETCH_JOB_INPUT =
362
      "SELECT " + COLUMN_SQI_ID + ", " + COLUMN_SQI_NAME + ", "
402
      "SELECT "
363
      + COLUMN_SQI_FORM + ", " + COLUMN_SQI_INDEX + ", " + COLUMN_SQI_TYPE
403
      + COLUMN_SQI_ID + ", "
364
      + ", " + COLUMN_SQI_STRMASK + ", " + COLUMN_SQI_STRLENGTH + ", "
404
      + COLUMN_SQI_NAME + ", "
365
      + COLUMN_SQI_ENUMVALS + ", " + COLUMN_SQBI_VALUE + " FROM "
405
      + COLUMN_SQI_FORM + ", "
366
      + TABLE_SQ_INPUT + " LEFT OUTER JOIN " + TABLE_SQ_JOB_INPUT + " ON "
406
      + COLUMN_SQI_INDEX + ", "
367
      + COLUMN_SQBI_INPUT + " = " + COLUMN_SQI_ID + " AND  " + COLUMN_SQBI_JOB
407
      + COLUMN_SQI_TYPE + ", "
368
      + " = ? WHERE " + COLUMN_SQI_FORM + " = ? AND (" + COLUMN_SQBI_JOB
408
      + COLUMN_SQI_STRMASK + ", "
369
      + " = ? OR " + COLUMN_SQBI_JOB + " IS NULL) ORDER BY "
409
      + COLUMN_SQI_STRLENGTH + ", "
370
      + COLUMN_SQI_INDEX;
410
      + COLUMN_SQI_ENUMVALS + ", "

    
   
411
      + COLUMN_SQBI_VALUE

    
   
412
      + " FROM " + TABLE_SQ_INPUT

    
   
413
      + " LEFT OUTER JOIN " + TABLE_SQ_JOB_INPUT

    
   
414
        + " ON " + COLUMN_SQBI_INPUT + " = " + COLUMN_SQI_ID

    
   
415
        + " AND  " + COLUMN_SQBI_JOB + " = ?"

    
   
416
      + " WHERE " + COLUMN_SQI_FORM + " = ?" +

    
   
417
        " AND (" + COLUMN_SQBI_JOB + " = ? OR " + COLUMN_SQBI_JOB + " IS NULL)"

    
   
418
      + " ORDER BY " + COLUMN_SQI_INDEX;
371

    
   
419

   
372
  // DML: Insert connector base
420
  // DML: Insert connector base
373
  public static final String STMT_INSERT_CONNECTOR_BASE =
421
  public static final String STMT_INSERT_CONNECTOR_BASE =
374
      "INSERT INTO " + TABLE_SQ_CONNECTOR + " ("
422
      "INSERT INTO " + TABLE_SQ_CONNECTOR + " ("
375
      + COLUMN_SQC_NAME + ", "
423
      + COLUMN_SQC_NAME + ", "
376
      + COLUMN_SQC_CLASS + ", "
424
      + COLUMN_SQC_CLASS + ", "
377
      + COLUMN_SQC_VERSION
425
      + COLUMN_SQC_VERSION
378
      + ") VALUES (?, ?, ?)";
426
      + ") VALUES (?, ?, ?)";
379

    
   
427

   
380
  // DML: Insert form base
428
  // DML: Insert form base
381
  public static final String STMT_INSERT_FORM_BASE =
429
  public static final String STMT_INSERT_FORM_BASE =
382
      "INSERT INTO " + TABLE_SQ_FORM + " (" + COLUMN_SQF_CONNECTOR + ", "
430
      "INSERT INTO " + TABLE_SQ_FORM + " ("
383
      + COLUMN_SQF_OPERATION + ", " + COLUMN_SQF_NAME + ", " + COLUMN_SQF_TYPE
431
      + COLUMN_SQF_CONNECTOR + ", "
384
      + ", " + COLUMN_SQF_INDEX + ") VALUES ( ?, ?, ?, ?, ?)";
432
      + COLUMN_SQF_OPERATION + ", "

    
   
433
      + COLUMN_SQF_NAME + ", "

    
   
434
      + COLUMN_SQF_TYPE + ", "

    
   
435
      + COLUMN_SQF_INDEX

    
   
436
      + ") VALUES ( ?, ?, ?, ?, ?)";
385

    
   
437

   
386
  // DML: Insert form input
438
  // DML: Insert form input
387
  public static final String STMT_INSERT_INPUT_BASE =
439
  public static final String STMT_INSERT_INPUT_BASE =
388
      "INSERT INTO " + TABLE_SQ_INPUT + " (" + COLUMN_SQI_NAME + ", "
440
      "INSERT INTO " + TABLE_SQ_INPUT + " ("
389
      + COLUMN_SQI_FORM + ", " + COLUMN_SQI_INDEX + ", " + COLUMN_SQI_TYPE
441
      + COLUMN_SQI_NAME + ", "
390
      + ", " + COLUMN_SQI_STRMASK + ", " + COLUMN_SQI_STRLENGTH + ", "
442
      + COLUMN_SQI_FORM + ", "
391
      + COLUMN_SQI_ENUMVALS + ") " + "VALUES (?, ?, ?, ?, ?, ?, ?)";
443
      + COLUMN_SQI_INDEX + ", "

    
   
444
      + COLUMN_SQI_TYPE + ", "

    
   
445
      + COLUMN_SQI_STRMASK + ", "

    
   
446
      + COLUMN_SQI_STRLENGTH + ", "

    
   
447
      + COLUMN_SQI_ENUMVALS

    
   
448
      + ") VALUES (?, ?, ?, ?, ?, ?, ?)";
392

    
   
449

   
393
  // DML: Insert new connection
450
  // DML: Insert new connection
394
  public static final String STMT_INSERT_CONNECTION =
451
  public static final String STMT_INSERT_CONNECTION =
395
    "INSERT INTO " + TABLE_SQ_CONNECTION + " ("
452
    "INSERT INTO " + TABLE_SQ_CONNECTION + " ("
396
    + COLUMN_SQN_NAME + ", "
453
    + COLUMN_SQN_NAME + ", "
[+20] [20] 17 lines
[+20]
414
    + COLUMN_SQN_UPDATE_DATE + " = ? "
471
    + COLUMN_SQN_UPDATE_DATE + " = ? "
415
    + " WHERE " + COLUMN_SQN_ID + " = ?";
472
    + " WHERE " + COLUMN_SQN_ID + " = ?";
416

    
   
473

   
417
  // DML: Delete rows from connection input table
474
  // DML: Delete rows from connection input table
418
  public static final String STMT_DELETE_CONNECTION_INPUT =
475
  public static final String STMT_DELETE_CONNECTION_INPUT =
419
    "DELETE FROM " + TABLE_SQ_CONNECTION_INPUT + " WHERE "
476
    "DELETE FROM " + TABLE_SQ_CONNECTION_INPUT
420
    + COLUMN_SQNI_CONNECTION + " = ?";
477
    + " WHERE " + COLUMN_SQNI_CONNECTION + " = ?";
421

    
   
478

   
422
  // DML: Delete row from connection table
479
  // DML: Delete row from connection table
423
  public static final String STMT_DELETE_CONNECTION =
480
  public static final String STMT_DELETE_CONNECTION =
424
    "DELETE FROM " + TABLE_SQ_CONNECTION + " WHERE " + COLUMN_SQN_ID + " = ?";
481
    "DELETE FROM " + TABLE_SQ_CONNECTION

    
   
482
    + " WHERE " + COLUMN_SQN_ID + " = ?";
425

    
   
483

   
426
  // DML: Select one specific connection
484
  // DML: Select one specific connection
427
  public static final String STMT_SELECT_CONNECTION_SINGLE =
485
  public static final String STMT_SELECT_CONNECTION_SINGLE =
428
    "SELECT "
486
    "SELECT "
429
    + COLUMN_SQN_ID + ", "
487
    + COLUMN_SQN_ID + ", "
[+20] [20] 14 lines
[+20]
444
    + COLUMN_SQN_UPDATE_DATE
502
    + COLUMN_SQN_UPDATE_DATE
445
    + " FROM " + TABLE_SQ_CONNECTION;
503
    + " FROM " + TABLE_SQ_CONNECTION;
446

    
   
504

   
447
  // DML: Check if given connection exists
505
  // DML: Check if given connection exists
448
  public static final String STMT_SELECT_CONNECTION_CHECK =
506
  public static final String STMT_SELECT_CONNECTION_CHECK =
449
    "SELECT count(*) FROM " + TABLE_SQ_CONNECTION + " WHERE " + COLUMN_SQN_ID
507
    "SELECT count(*) FROM " + TABLE_SQ_CONNECTION
450
    + " = ?";
508
    + " WHERE " + COLUMN_SQN_ID + " = ?";
451

    
   
509

   
452
  // DML: Insert new job
510
  // DML: Insert new job
453
  public static final String STMT_INSERT_JOB =
511
  public static final String STMT_INSERT_JOB =
454
    "INSERT INTO " + TABLE_SQ_JOB + " ("
512
    "INSERT INTO " + TABLE_SQ_JOB + " ("
455
    + COLUMN_SQB_NAME + ", "
513
    + COLUMN_SQB_NAME + ", "
[+20] [20] 17 lines
[+20]
473
    + COLUMN_SQB_UPDATE_DATE + " = ? "
531
    + COLUMN_SQB_UPDATE_DATE + " = ? "
474
    + " WHERE " + COLUMN_SQB_ID + " = ?";
532
    + " WHERE " + COLUMN_SQB_ID + " = ?";
475

    
   
533

   
476
  // DML: Delete rows from job input table
534
  // DML: Delete rows from job input table
477
  public static final String STMT_DELETE_JOB_INPUT =
535
  public static final String STMT_DELETE_JOB_INPUT =
478
    "DELETE FROM " + TABLE_SQ_JOB_INPUT + " WHERE " + COLUMN_SQBI_JOB + " = ?";
536
    "DELETE FROM " + TABLE_SQ_JOB_INPUT

    
   
537
    + " WHERE " + COLUMN_SQBI_JOB + " = ?";
479

    
   
538

   
480
  // DML: Delete row from job table
539
  // DML: Delete row from job table
481
  public static final String STMT_DELETE_JOB =
540
  public static final String STMT_DELETE_JOB =
482
    "DELETE FROM " + TABLE_SQ_JOB + " WHERE " + COLUMN_SQB_ID + " = ?";
541
    "DELETE FROM " + TABLE_SQ_JOB

    
   
542
    + " WHERE " + COLUMN_SQB_ID + " = ?";
483

    
   
543

   
484
  // DML: Check if given job exists
544
  // DML: Check if given job exists
485
  public static final String STMT_SELECT_JOB_CHECK =
545
  public static final String STMT_SELECT_JOB_CHECK =
486
    "SELECT count(*) FROM " + TABLE_SQ_JOB + " WHERE " + COLUMN_SQB_ID + " = ?";
546
    "SELECT count(*) FROM " + TABLE_SQ_JOB

    
   
547
    + " WHERE " + COLUMN_SQB_ID + " = ?";
487

    
   
548

   
488
  // DML: Check if there are jobs for given connection
549
  // DML: Check if there are jobs for given connection
489
  public static final String STMT_SELECT_JOBS_FOR_CONNECTION_CHECK =
550
  public static final String STMT_SELECT_JOBS_FOR_CONNECTION_CHECK =
490
    "SELECT count(*) FROM " + TABLE_SQ_JOB + " JOIN " + TABLE_SQ_CONNECTION
551
    "SELECT"
491
    + " ON " + COLUMN_SQB_CONNECTION + " = " + COLUMN_SQN_ID + " WHERE "
552
    + " count(*)"
492
    + COLUMN_SQN_ID + " = ? ";
553
    + " FROM " + TABLE_SQ_JOB

    
   
554
    + " JOIN " + TABLE_SQ_CONNECTION

    
   
555
      + " ON " + COLUMN_SQB_CONNECTION + " = " + COLUMN_SQN_ID

    
   
556
    + " WHERE " + COLUMN_SQN_ID + " = ? ";
493

    
   
557

   
494
  // DML: Select one specific job
558
  // DML: Select one specific job
495
  public static final String STMT_SELECT_JOB_SINGLE =
559
  public static final String STMT_SELECT_JOB_SINGLE =
496
    "SELECT "
560
    "SELECT "
497
    + COLUMN_SQN_CONNECTOR + ", "
561
    + COLUMN_SQN_CONNECTOR + ", "
498
    + COLUMN_SQB_ID + ", "
562
    + COLUMN_SQB_ID + ", "
499
    + COLUMN_SQB_NAME + ", "
563
    + COLUMN_SQB_NAME + ", "
500
    + COLUMN_SQB_CONNECTION + ", "
564
    + COLUMN_SQB_CONNECTION + ", "
501
    + COLUMN_SQB_TYPE + ", "
565
    + COLUMN_SQB_TYPE + ", "
502
    + COLUMN_SQB_CREATION_DATE + ", "
566
    + COLUMN_SQB_CREATION_DATE + ", "
503
    + COLUMN_SQB_UPDATE_DATE
567
    + COLUMN_SQB_UPDATE_DATE
504
    + " FROM " + TABLE_SQ_JOB
568
    + " FROM " + TABLE_SQ_JOB
505
    + " LEFT JOIN " + TABLE_SQ_CONNECTION + " ON " + COLUMN_SQB_CONNECTION + " = " + COLUMN_SQN_ID
569
    + " LEFT JOIN " + TABLE_SQ_CONNECTION

    
   
570
      + " ON " + COLUMN_SQB_CONNECTION + " = " + COLUMN_SQN_ID
506
    + " WHERE " + COLUMN_SQB_ID + " = ?";
571
    + " WHERE " + COLUMN_SQB_ID + " = ?";
507

    
   
572

   
508
  // DML: Select all jobs
573
  // DML: Select all jobs
509
  public static final String STMT_SELECT_JOB_ALL =
574
  public static final String STMT_SELECT_JOB_ALL =
510
    "SELECT "
575
    "SELECT "
511
    + COLUMN_SQN_CONNECTOR + ", "
576
    + COLUMN_SQN_CONNECTOR + ", "
512
    + COLUMN_SQB_ID + ", "
577
    + COLUMN_SQB_ID + ", "
513
    + COLUMN_SQB_NAME + ", "
578
    + COLUMN_SQB_NAME + ", "
514
    + COLUMN_SQB_CONNECTION + ", "
579
    + COLUMN_SQB_CONNECTION + ", "
515
    + COLUMN_SQB_TYPE + ", "
580
    + COLUMN_SQB_TYPE + ", "
516
    + COLUMN_SQB_CREATION_DATE + ", "
581
    + COLUMN_SQB_CREATION_DATE + ", "
517
    + COLUMN_SQB_UPDATE_DATE
582
    + COLUMN_SQB_UPDATE_DATE
518
    + " FROM " + TABLE_SQ_JOB + " LEFT JOIN " + TABLE_SQ_CONNECTION + " ON " + COLUMN_SQB_CONNECTION + " = " + COLUMN_SQN_ID;
583
    + " FROM " + TABLE_SQ_JOB

    
   
584
    + " LEFT JOIN " + TABLE_SQ_CONNECTION

    
   
585
      + " ON " + COLUMN_SQB_CONNECTION + " = " + COLUMN_SQN_ID;
519

    
   
586

   
520
  // DML: Insert new submission
587
  // DML: Insert new submission
521
  public static final String STMT_INSERT_SUBMISSION =
588
  public static final String STMT_INSERT_SUBMISSION =
522
    "INSERT INTO " + TABLE_SQ_SUBMISSION + "("
589
    "INSERT INTO " + TABLE_SQ_SUBMISSION + "("
523
    + COLUMN_SQS_JOB + ", "
590
    + COLUMN_SQS_JOB + ", "
[+20] [20] 15 lines
[+20]
539
    + COLUMN_SQS_EXCEPTION_TRACE + " = ?"
606
    + COLUMN_SQS_EXCEPTION_TRACE + " = ?"
540
    + " WHERE " + COLUMN_SQS_ID + " = ?";
607
    + " WHERE " + COLUMN_SQS_ID + " = ?";
541

    
   
608

   
542
  // DML: Check if given submission exists
609
  // DML: Check if given submission exists
543
  public static final String STMT_SELECT_SUBMISSION_CHECK =
610
  public static final String STMT_SELECT_SUBMISSION_CHECK =
544
    "SELECT count(*) FROM " + TABLE_SQ_SUBMISSION + " WHERE " + COLUMN_SQS_ID
611
    "SELECT"
545
      + " = ?";
612
    + " count(*)"

    
   
613
    + " FROM " + TABLE_SQ_SUBMISSION

    
   
614
    + " WHERE " + COLUMN_SQS_ID + " = ?";
546

    
   
615

   
547
  // DML: Purge old entries
616
  // DML: Purge old entries
548
  public static final String STMT_PURGE_SUBMISSIONS =
617
  public static final String STMT_PURGE_SUBMISSIONS =
549
    "DELETE FROM " + TABLE_SQ_SUBMISSION
618
    "DELETE FROM " + TABLE_SQ_SUBMISSION
550
    + " WHERE " + COLUMN_SQS_UPDATE_DATE + " < ?";
619
    + " WHERE " + COLUMN_SQS_UPDATE_DATE + " < ?";
[+20] [20] 71 lines
[+20]
622
    "SELECT "
691
    "SELECT "
623
    + COLUMN_SQG_NAME + ", "
692
    + COLUMN_SQG_NAME + ", "
624
    + COLUMN_SQR_NAME + ", "
693
    + COLUMN_SQR_NAME + ", "
625
    + COLUMN_SQRS_VALUE + " "
694
    + COLUMN_SQRS_VALUE + " "
626
    + "FROM " + TABLE_SQ_COUNTER_SUBMISSION + " "
695
    + "FROM " + TABLE_SQ_COUNTER_SUBMISSION + " "
627
    + "LEFT JOIN " + TABLE_SQ_COUNTER_GROUP + " ON " + COLUMN_SQRS_GROUP + " = " + COLUMN_SQG_ID + " "
696
    + "LEFT JOIN " + TABLE_SQ_COUNTER_GROUP
628
    + "LEFT JOIN " + TABLE_SQ_COUNTER + " ON " + COLUMN_SQRS_COUNTER + " = " + COLUMN_SQR_ID + " "
697
      + " ON " + COLUMN_SQRS_GROUP + " = " + COLUMN_SQG_ID + " "

    
   
698
    + "LEFT JOIN " + TABLE_SQ_COUNTER

    
   
699
      + " ON " + COLUMN_SQRS_COUNTER + " = " + COLUMN_SQR_ID + " "
629
    + "WHERE " + COLUMN_SQRS_SUBMISSION + " = ? ";
700
    + "WHERE " + COLUMN_SQRS_SUBMISSION + " = ? ";
630

    
   
701

   
631
  // DML: Delete rows from counter submission table
702
  // DML: Delete rows from counter submission table
632
  public static final String STMT_DELETE_COUNTER_SUBMISSION =
703
  public static final String STMT_DELETE_COUNTER_SUBMISSION =
633
    "DELETE FROM " + TABLE_SQ_COUNTER_SUBMISSION
704
    "DELETE FROM " + TABLE_SQ_COUNTER_SUBMISSION
634
    + " WHERE " + COLUMN_SQRS_SUBMISSION + " = ?";
705
    + " WHERE " + COLUMN_SQRS_SUBMISSION + " = ?";
635

    
   
706

   
636

    
   
707

   
637
  private DerbySchemaQuery() {
708
  private DerbySchemaQuery() {
638
    // Disable explicit object creation
709
    // Disable explicit object creation
639
  }
710
  }
640
}
711
}
  1. repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java: Loading...