forked from cwensel/cascading.jdbc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add AsterData vendor specific overrides.
- Loading branch information
Showing
5 changed files
with
288 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/java/cascading/jdbc/asterdata/ADDimensionTableDesc.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,36 @@ | ||
/* | ||
* Copyright (c) 2009 Concurrent, Inc. | ||
* | ||
* This work has been released into the public domain | ||
* by the copyright holder. This applies worldwide. | ||
* | ||
* In case this is not legally possible: | ||
* The copyright holder grants any entity the right | ||
* to use this work for any purpose, without any | ||
* conditions, unless such conditions are required by law. | ||
*/ | ||
|
||
package cascading.jdbc.asterdata; | ||
|
||
/** | ||
* | ||
*/ | ||
public class ADDimensionTableDesc extends AsterDataTableDesc | ||
{ | ||
public ADDimensionTableDesc( String tableName, String[] columnNames, String[] columnDefs, String[] primaryKeys, String partitionKey ) | ||
{ | ||
super( tableName, columnNames, columnDefs, primaryKeys, partitionKey ); | ||
} | ||
|
||
@Override | ||
protected String getCreateTableFormat() | ||
{ | ||
return "CREATE DIMENSION TABLE %s ( %s )"; | ||
} | ||
|
||
@Override | ||
protected String getDropTableFormat() | ||
{ | ||
return "DROP TABLE %s CASCADE"; | ||
} | ||
} |
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,36 @@ | ||
/* | ||
* Copyright (c) 2009 Concurrent, Inc. | ||
* | ||
* This work has been released into the public domain | ||
* by the copyright holder. This applies worldwide. | ||
* | ||
* In case this is not legally possible: | ||
* The copyright holder grants any entity the right | ||
* to use this work for any purpose, without any | ||
* conditions, unless such conditions are required by law. | ||
*/ | ||
|
||
package cascading.jdbc.asterdata; | ||
|
||
/** | ||
* | ||
*/ | ||
public class ADFactTableDesc extends AsterDataTableDesc | ||
{ | ||
public ADFactTableDesc( String tableName, String[] columnNames, String[] columnDefs, String[] primaryKeys, String partitionKey ) | ||
{ | ||
super( tableName, columnNames, columnDefs, primaryKeys, partitionKey ); | ||
} | ||
|
||
@Override | ||
protected String getCreateTableFormat() | ||
{ | ||
return "CREATE FACT TABLE %s ( %s )"; | ||
} | ||
|
||
@Override | ||
protected String getDropTableFormat() | ||
{ | ||
return "DROP TABLE %s CASCADE"; | ||
} | ||
} |
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,31 @@ | ||
/* | ||
* Copyright (c) 2009 Concurrent, Inc. | ||
* | ||
* This work has been released into the public domain | ||
* by the copyright holder. This applies worldwide. | ||
* | ||
* In case this is not legally possible: | ||
* The copyright holder grants any entity the right | ||
* to use this work for any purpose, without any | ||
* conditions, unless such conditions are required by law. | ||
*/ | ||
|
||
package cascading.jdbc.asterdata; | ||
|
||
import java.sql.Connection; | ||
|
||
import cascading.jdbc.db.DBInputFormat; | ||
|
||
/** This DBInputFormat subclass simply disables the transaction isolation level setting. */ | ||
public class ADInputFormat extends DBInputFormat | ||
{ | ||
public ADInputFormat() | ||
{ | ||
} | ||
|
||
@Override | ||
protected void setTransactionIsolationLevel( Connection connection ) | ||
{ | ||
// do nothing | ||
} | ||
} |
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,127 @@ | ||
/* | ||
* Copyright (c) 2009 Concurrent, Inc. | ||
* | ||
* This work has been released into the public domain | ||
* by the copyright holder. This applies worldwide. | ||
* | ||
* In case this is not legally possible: | ||
* The copyright holder grants any entity the right | ||
* to use this work for any purpose, without any | ||
* conditions, unless such conditions are required by law. | ||
*/ | ||
|
||
package cascading.jdbc.asterdata; | ||
|
||
import cascading.jdbc.JDBCScheme; | ||
import cascading.tuple.Fields; | ||
import cascading.tuple.Tuple; | ||
|
||
/** | ||
* | ||
*/ | ||
public class AsterDataScheme extends JDBCScheme | ||
{ | ||
public AsterDataScheme( String[] columns, String[] orderBy, String conditions, String[] updateBy ) | ||
{ | ||
super( ADInputFormat.class, null, columns, orderBy, conditions, updateBy ); | ||
} | ||
|
||
public AsterDataScheme( Fields columnFields, String[] columns, String[] orderBy, String conditions, Fields updateByFields, String[] updateBy ) | ||
{ | ||
super( ADInputFormat.class, null, columnFields, columns, orderBy, conditions, updateByFields, updateBy ); | ||
} | ||
|
||
public AsterDataScheme( String[] columns, String[] orderBy, String conditions, long limit ) | ||
{ | ||
super( ADInputFormat.class, null, columns, orderBy, conditions, limit, null ); | ||
} | ||
|
||
public AsterDataScheme( Fields columnFields, String[] columns, String[] orderBy, String conditions, long limit ) | ||
{ | ||
super( ADInputFormat.class, null, columnFields, columns, orderBy, conditions, limit, null, null ); | ||
} | ||
|
||
public AsterDataScheme( String[] columns, String[] orderBy, String conditions ) | ||
{ | ||
super( ADInputFormat.class, null, columns, orderBy, conditions, null ); | ||
} | ||
|
||
public AsterDataScheme( Fields columnFields, String[] columns, String[] orderBy, String conditions ) | ||
{ | ||
super( ADInputFormat.class, null, columnFields, columns, orderBy, conditions, null, null ); | ||
} | ||
|
||
public AsterDataScheme( String[] columns, String[] orderBy, String[] updateBy ) | ||
{ | ||
super( ADInputFormat.class, null, columns, orderBy, updateBy ); | ||
} | ||
|
||
public AsterDataScheme( Fields columnFields, String[] columns, String[] orderBy, Fields updateByFields, String[] updateBy ) | ||
{ | ||
super( ADInputFormat.class, null, columnFields, columns, orderBy, updateByFields, updateBy ); | ||
} | ||
|
||
public AsterDataScheme( String[] columns, String[] orderBy ) | ||
{ | ||
this( columns, orderBy, null, null ); | ||
} | ||
|
||
public AsterDataScheme( Fields columnFields, String[] columns, String[] orderBy ) | ||
{ | ||
this( columnFields, columns, orderBy, null, null ); | ||
} | ||
|
||
public AsterDataScheme( String[] columns, long limit ) | ||
{ | ||
this( columns, (String[]) null, null, limit ); | ||
} | ||
|
||
public AsterDataScheme( Fields columnFields, String[] columns, long limit ) | ||
{ | ||
this( columnFields, columns, (String[]) null, null, limit ); | ||
} | ||
|
||
public AsterDataScheme( String[] columns ) | ||
{ | ||
this( columns, null, null, null ); | ||
} | ||
|
||
public AsterDataScheme( Fields columnFields, String[] columns ) | ||
{ | ||
this( columnFields, columns, null, null, null ); | ||
} | ||
|
||
public AsterDataScheme( String[] columns, String selectQuery, String countQuery ) | ||
{ | ||
super( ADInputFormat.class, columns, selectQuery, countQuery, -1 ); | ||
} | ||
|
||
public AsterDataScheme( Fields columnFields, String[] columns, String selectQuery, String countQuery ) | ||
{ | ||
super( ADInputFormat.class, columnFields, columns, selectQuery, countQuery, -1 ); | ||
} | ||
|
||
public AsterDataScheme( String[] columns, String selectQuery, String countQuery, long limit ) | ||
{ | ||
super( ADInputFormat.class, columns, selectQuery, countQuery, limit ); | ||
} | ||
|
||
public AsterDataScheme( Fields columnFields, String[] columns, String selectQuery, String countQuery, long limit ) | ||
{ | ||
super( ADInputFormat.class, columnFields, columns, selectQuery, countQuery, limit ); | ||
} | ||
|
||
@Override | ||
protected Tuple cleanTuple( Tuple result ) | ||
{ | ||
for( int i = 0; i < result.size(); i++ ) | ||
{ | ||
Comparable value = result.get( i ); | ||
|
||
if( value instanceof String ) | ||
result.set( i, ( (String) value ).replaceAll( "'", "''" ) ); | ||
} | ||
|
||
return result; | ||
} | ||
} |
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,58 @@ | ||
/* | ||
* Copyright (c) 2009 Concurrent, Inc. | ||
* | ||
* This work has been released into the public domain | ||
* by the copyright holder. This applies worldwide. | ||
* | ||
* In case this is not legally possible: | ||
* The copyright holder grants any entity the right | ||
* to use this work for any purpose, without any | ||
* conditions, unless such conditions are required by law. | ||
*/ | ||
|
||
package cascading.jdbc.asterdata; | ||
|
||
import java.util.List; | ||
|
||
import cascading.jdbc.TableDesc; | ||
|
||
/** | ||
* | ||
*/ | ||
public class AsterDataTableDesc extends TableDesc | ||
{ | ||
/** Field partitionKey */ | ||
protected String partitionKey; | ||
|
||
public AsterDataTableDesc( String tableName ) | ||
{ | ||
super( tableName ); | ||
} | ||
|
||
public AsterDataTableDesc( String tableName, String[] columnNames, String[] columnDefs, String[] primaryKeys ) | ||
{ | ||
super( tableName, columnNames, columnDefs, primaryKeys ); | ||
} | ||
|
||
public AsterDataTableDesc( String tableName, String[] columnNames, String[] columnDefs, String[] primaryKeys, String partitionKey ) | ||
{ | ||
super( tableName, columnNames, columnDefs, primaryKeys ); | ||
this.partitionKey = partitionKey; | ||
} | ||
|
||
@Override | ||
protected List<String> addCreateTableBodyTo( List<String> createTableStatement ) | ||
{ | ||
createTableStatement = super.addCreateTableBodyTo( createTableStatement ); | ||
|
||
if( hasPartitionKey() ) | ||
createTableStatement.add( String.format( "PARTITION KEY( %s )", partitionKey ) ); | ||
|
||
return createTableStatement; | ||
} | ||
|
||
private boolean hasPartitionKey() | ||
{ | ||
return partitionKey != null && partitionKey.length() != 0; | ||
} | ||
} |