-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support for diffs on Create Search Index (#104)
- Loading branch information
Showing
24 changed files
with
821 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/google/cloud/solutions/spannerddl/diff/SchemaUpdateStatements.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,41 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.solutions.spannerddl.diff; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.common.collect.ImmutableList; | ||
import java.util.List; | ||
|
||
/** Simple container class to hold a set of drop, modify and create statements. */ | ||
@AutoValue | ||
public abstract class SchemaUpdateStatements { | ||
|
||
/** Creates an instance storing the specified statements. */ | ||
public static SchemaUpdateStatements create( | ||
List<String> dropStatements, List<String> modifyStatements, List<String> createStatements) { | ||
return new AutoValue_SchemaUpdateStatements( | ||
ImmutableList.copyOf(dropStatements), | ||
ImmutableList.copyOf(modifyStatements), | ||
ImmutableList.copyOf(createStatements)); | ||
} | ||
|
||
public abstract ImmutableList<String> dropStatements(); | ||
|
||
public abstract ImmutableList<String> modifyStatements(); | ||
|
||
public abstract ImmutableList<String> createStatements(); | ||
} |
28 changes: 28 additions & 0 deletions
28
...in/java/com/google/cloud/solutions/spannerddl/parser/ASTalter_search_index_statement.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,28 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.solutions.spannerddl.parser; | ||
|
||
public class ASTalter_search_index_statement extends SimpleNode { | ||
public ASTalter_search_index_statement(int id) { | ||
super(id); | ||
throw new UnsupportedOperationException("Not Implemented"); | ||
} | ||
|
||
public ASTalter_search_index_statement(DdlParser p, int id) { | ||
super(p, id); | ||
throw new UnsupportedOperationException("Not Implemented"); | ||
} | ||
} |
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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_index_where_clause.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,55 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.solutions.spannerddl.parser; | ||
|
||
import static com.google.cloud.solutions.spannerddl.diff.AstTreeUtils.validateChildrenClass; | ||
|
||
import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils; | ||
import com.google.common.base.Joiner; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class ASTcreate_index_where_clause extends SimpleNode { | ||
public ASTcreate_index_where_clause(int id) { | ||
super(id); | ||
} | ||
|
||
public ASTcreate_index_where_clause(DdlParser p, int id) { | ||
super(p, id); | ||
} | ||
|
||
/** | ||
* void create_index_where_clause() : {} { path() <IS> <NOT> <NULLL> (<AND> path() <IS> <NOT> | ||
* <NULLL>)* } | ||
*/ | ||
@Override | ||
public String toString() { | ||
validateChildrenClass(children, ASTpath.class); | ||
|
||
// convert paths object to "pathName IS NOT NULL" to make joining easier. | ||
List<String> paths = | ||
AstTreeUtils.getChildrenAssertType(children, ASTpath.class).stream() | ||
.map((ASTpath path) -> path.toString() + " IS NOT NULL") | ||
.collect(Collectors.toList()); | ||
|
||
return "WHERE " + Joiner.on(" AND ").join(paths); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return toString().hashCode(); | ||
} | ||
} |
Oops, something went wrong.