-
Notifications
You must be signed in to change notification settings - Fork 990
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Introduce View Support to HiveCatalog
- Loading branch information
1 parent
347ae21
commit 9fd50c7
Showing
10 changed files
with
629 additions
and
28 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
49 changes: 49 additions & 0 deletions
49
paimon-core/src/main/java/org/apache/paimon/view/View.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,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 | ||
* | ||
* http://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 org.apache.paimon.view; | ||
|
||
import org.apache.paimon.types.RowType; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** Interface for view definition. */ | ||
public interface View { | ||
|
||
/** A name to identify this view. */ | ||
String name(); | ||
|
||
/** Full name (including database) to identify this view. */ | ||
String fullName(); | ||
|
||
/** Returns the row type of this view. */ | ||
RowType rowType(); | ||
|
||
/** Returns the view representation. */ | ||
String query(); | ||
|
||
/** Optional comment of this view. */ | ||
Optional<String> comment(); | ||
|
||
/** Options of this view. */ | ||
Map<String, String> options(); | ||
|
||
/** Copy this view with adding dynamic options. */ | ||
View copy(Map<String, String> dynamicOptions); | ||
} |
110 changes: 110 additions & 0 deletions
110
paimon-core/src/main/java/org/apache/paimon/view/ViewImpl.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,110 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 | ||
* | ||
* http://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 org.apache.paimon.view; | ||
|
||
import org.apache.paimon.catalog.Identifier; | ||
import org.apache.paimon.types.RowType; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** Implementation of {@link View}. */ | ||
public class ViewImpl implements View { | ||
|
||
private final Identifier identifier; | ||
private final RowType rowType; | ||
private final String query; | ||
@Nullable private final String comment; | ||
private final Map<String, String> options; | ||
|
||
public ViewImpl( | ||
Identifier identifier, | ||
RowType rowType, | ||
String query, | ||
@Nullable String comment, | ||
Map<String, String> options) { | ||
this.identifier = identifier; | ||
this.rowType = rowType; | ||
this.query = query; | ||
this.comment = comment; | ||
this.options = options; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return identifier.getObjectName(); | ||
} | ||
|
||
@Override | ||
public String fullName() { | ||
return identifier.getFullName(); | ||
} | ||
|
||
@Override | ||
public RowType rowType() { | ||
return rowType; | ||
} | ||
|
||
@Override | ||
public String query() { | ||
return query; | ||
} | ||
|
||
@Override | ||
public Optional<String> comment() { | ||
return Optional.ofNullable(comment); | ||
} | ||
|
||
@Override | ||
public Map<String, String> options() { | ||
return options; | ||
} | ||
|
||
@Override | ||
public View copy(Map<String, String> dynamicOptions) { | ||
Map<String, String> newOptions = new HashMap<>(options); | ||
newOptions.putAll(dynamicOptions); | ||
return new ViewImpl(identifier, rowType, query, comment, newOptions); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
ViewImpl view = (ViewImpl) o; | ||
return Objects.equals(identifier, view.identifier) | ||
&& Objects.equals(rowType, view.rowType) | ||
&& Objects.equals(query, view.query) | ||
&& Objects.equals(comment, view.comment) | ||
&& Objects.equals(options, view.options); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(identifier, rowType, query, comment, options); | ||
} | ||
} |
Oops, something went wrong.