@@ -63,36 +63,44 @@ public Table(String name) {
63
63
}
64
64
65
65
public Table (String schemaName , String name ) {
66
- setName (name );
67
66
setSchemaName (schemaName );
67
+ setName (name );
68
68
}
69
69
70
70
public Table (Database database , String schemaName , String name ) {
71
- setName (name );
72
- setSchemaName (schemaName );
73
71
setDatabase (database );
72
+ setSchemaName (schemaName );
73
+ setName (name );
74
74
}
75
75
76
76
public Table (String catalogName , String schemaName , String tableName ) {
77
- setName (tableName );
78
77
setSchemaName (schemaName );
79
78
setDatabase (new Database (catalogName ));
79
+ setName (tableName );
80
80
}
81
81
82
82
public Table (List <String > partItems ) {
83
- this .partItems = new ArrayList <>(partItems );
84
- Collections .reverse (this .partItems );
83
+ if (partItems .size () == 1 ) {
84
+ setName (partItems .get (0 ));
85
+ } else {
86
+ this .partItems = new ArrayList <>(partItems );
87
+ Collections .reverse (this .partItems );
88
+ }
85
89
}
86
90
87
91
public Table (List <String > partItems , List <String > partDelimiters ) {
88
- if (partDelimiters .size () != partItems .size () - 1 ) {
89
- throw new IllegalArgumentException (
90
- "the length of the delimiters list must be 1 less than nameParts" );
92
+ if (partItems .size () == 1 ) {
93
+ setName (partItems .get (0 ));
94
+ } else {
95
+ if (partDelimiters .size () != partItems .size () - 1 ) {
96
+ throw new IllegalArgumentException (
97
+ "the length of the delimiters list must be 1 less than nameParts" );
98
+ }
99
+ this .partItems = new ArrayList <>(partItems );
100
+ this .partDelimiters = new ArrayList <>(partDelimiters );
101
+ Collections .reverse (this .partItems );
102
+ Collections .reverse (this .partDelimiters );
91
103
}
92
- this .partItems = new ArrayList <>(partItems );
93
- this .partDelimiters = new ArrayList <>(partDelimiters );
94
- Collections .reverse (this .partItems );
95
- Collections .reverse (this .partDelimiters );
96
104
}
97
105
98
106
public String getCatalogName () {
@@ -159,7 +167,17 @@ public String getName() {
159
167
160
168
161
169
public void setName (String name ) {
162
- setIndex (NAME_IDX , name );
170
+ // BigQuery seems to allow things like: `catalogName.schemaName.tableName` in only one pair
171
+ // of quotes
172
+ if (MultiPartName .isQuoted (name ) && name .contains ("." )) {
173
+ partItems .clear ();
174
+ for (String unquotedIdentifier : MultiPartName .unquote (name ).split ("\\ ." )) {
175
+ partItems .add ("\" " + unquotedIdentifier + "\" " );
176
+ }
177
+ Collections .reverse (partItems );
178
+ } else {
179
+ setIndex (NAME_IDX , name );
180
+ }
163
181
}
164
182
165
183
public String getDBLinkName () {
0 commit comments