-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added information_schema.schemata listing all available table schemas
- Loading branch information
Showing
8 changed files
with
190 additions
and
48 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
58 changes: 58 additions & 0 deletions
58
sql/src/main/java/io/crate/metadata/information/InformationSchemataTableInfo.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,58 @@ | ||
/* | ||
* Licensed to CRATE Technology GmbH ("Crate") under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. Crate 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. | ||
* | ||
* However, if you have executed another commercial license agreement | ||
* with Crate these terms will supersede the license and you may use the | ||
* software solely pursuant to the terms of the relevant commercial agreement. | ||
*/ | ||
|
||
package io.crate.metadata.information; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import io.crate.metadata.ColumnIdent; | ||
import io.crate.metadata.ReferenceIdent; | ||
import io.crate.metadata.ReferenceInfo; | ||
import io.crate.metadata.TableIdent; | ||
import io.crate.planner.RowGranularity; | ||
import io.crate.types.DataType; | ||
import io.crate.types.DataTypes; | ||
|
||
public class InformationSchemataTableInfo extends InformationTableInfo { | ||
|
||
public static final String NAME = "schemata"; | ||
public static final TableIdent IDENT = new TableIdent(InformationSchemaInfo.NAME, NAME); | ||
|
||
public static class Columns { | ||
public static final ColumnIdent SCHEMA_NAME = new ColumnIdent("schema_name"); | ||
} | ||
|
||
public static class ReferenceInfos { | ||
public static final ReferenceInfo SCHEMA_NAME = info(Columns.SCHEMA_NAME, DataTypes.STRING); | ||
} | ||
|
||
private static ReferenceInfo info(ColumnIdent columnIdent, DataType dataType) { | ||
return new ReferenceInfo(new ReferenceIdent(IDENT, columnIdent), RowGranularity.DOC, dataType); | ||
} | ||
|
||
protected InformationSchemataTableInfo(InformationSchemaInfo schemaInfo) { | ||
super(schemaInfo, IDENT, | ||
ImmutableList.of(Columns.SCHEMA_NAME), | ||
ImmutableMap.of(Columns.SCHEMA_NAME, ReferenceInfos.SCHEMA_NAME), | ||
ImmutableList.of(ReferenceInfos.SCHEMA_NAME) | ||
); | ||
} | ||
} |
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
...src/main/java/io/crate/operation/reference/information/InformationSchemataExpression.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 CRATE Technology GmbH ("Crate") under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. Crate 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. | ||
* | ||
* However, if you have executed another commercial license agreement | ||
* with Crate these terms will supersede the license and you may use the | ||
* software solely pursuant to the terms of the relevant commercial agreement. | ||
*/ | ||
|
||
package io.crate.operation.reference.information; | ||
|
||
import io.crate.metadata.ReferenceInfo; | ||
import io.crate.metadata.information.InformationSchemataTableInfo; | ||
import io.crate.metadata.information.RowCollectExpression; | ||
import io.crate.metadata.table.SchemaInfo; | ||
import org.apache.lucene.util.BytesRef; | ||
|
||
public abstract class InformationSchemataExpression<T> extends RowCollectExpression<SchemaInfo, T> { | ||
|
||
public static final SchemataSchemaNameExpression SCHEMA_NAME_EXPRESSION = new SchemataSchemaNameExpression(); | ||
|
||
protected InformationSchemataExpression(ReferenceInfo info) { | ||
super(info); | ||
} | ||
|
||
private static class SchemataSchemaNameExpression extends InformationSchemataExpression<BytesRef> { | ||
|
||
protected SchemataSchemaNameExpression() { | ||
super(InformationSchemataTableInfo.ReferenceInfos.SCHEMA_NAME); | ||
} | ||
|
||
@Override | ||
public BytesRef value() { | ||
return new BytesRef(this.row.name()); | ||
} | ||
} | ||
} |
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