Package org.apache.calcite.model
Class JsonView
- java.lang.Object
-
- org.apache.calcite.model.JsonTable
-
- org.apache.calcite.model.JsonView
-
public class JsonView extends JsonTable
View schema element.Like base class
JsonTable
, occurs withinJsonMapSchema.tables
.Modifiable views
A view is modifiable if contains only SELECT, FROM, WHERE (no JOIN, aggregation or sub-queries) and every column:
- is specified once in the SELECT clause; or
- occurs in the WHERE clause with a column = literal predicate; or
- is nullable.
The second clause allows Calcite to automatically provide the correct value for hidden columns. It is useful in, say, a multi-tenant environment, where the
tenantId
column is hidden, mandatory (NOT NULL), and has a constant value for a particular view.Errors regarding modifiable views:
- If a view is marked modifiable: true and is not modifiable, Calcite throws an error while reading the schema.
- If you submit an INSERT, UPDATE or UPSERT command to a non-modifiable view, Calcite throws an error when validating the statement.
- If a DML statement creates a row that would not appear in the view (for example, a row in female_emps, above, with gender = 'M'), Calcite throws an error when executing the statement.
- See Also:
Description of schema elements
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.Boolean
modifiable
Whether this view should allow INSERT requests.java.util.List<java.lang.String>
path
Schema name(s) to use when resolving query.java.lang.Object
sql
SQL query that is the definition of the view.
-
Constructor Summary
Constructors Constructor Description JsonView()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(ModelHandler handler)
java.lang.String
getSql()
Returns the SQL query as a string, concatenating a list of lines if necessary.java.lang.String
toString()
-
-
-
Field Detail
-
sql
public java.lang.Object sql
SQL query that is the definition of the view.Must be a string or a list of strings (which are concatenated into a multi-line SQL string, separated by newlines).
-
path
public java.util.List<java.lang.String> path
Schema name(s) to use when resolving query.If not specified, defaults to current schema.
-
modifiable
public java.lang.Boolean modifiable
Whether this view should allow INSERT requests.The values have the following meanings:
- If true, Calcite throws an error when validating the schema if the view is not modifiable.
- If null, Calcite deduces whether the view is modifiable.
- If false, Calcite will not allow inserts.
The default value is
null
.
-
-
Method Detail
-
accept
public void accept(ModelHandler handler)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getSql
public java.lang.String getSql()
Returns the SQL query as a string, concatenating a list of lines if necessary.
-
-