use of org.apache.ignite.internal.processors.query.stat.StatisticsTarget in project ignite by apache.
the class SqlStatisticsCommands method parse.
/**
* {@inheritDoc}
*/
@Override
public SqlCommand parse(SqlLexer lex) {
while (true) {
SqlQualifiedName tblQName = parseQualifiedIdentifier(lex);
String[] cols = parseColumnList(lex, false);
targets.add(new StatisticsTarget(tblQName.schemaName(), tblQName.name(), cols));
if (tryEnd(lex))
return this;
}
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsTarget in project ignite by apache.
the class SqlParserAnalyzeSelfTest method testAnalyze.
/**
* Tests for ANALYZE command.
*/
@Test
public void testAnalyze() {
parseValidate(null, "ANALYZE tbl", new StatisticsTarget((String) null, "TBL"));
parseValidate(null, "ANALYZE tbl;", new StatisticsTarget((String) null, "TBL"));
parseValidate(null, "ANALYZE schema.tbl", new StatisticsTarget("SCHEMA", "TBL"));
parseValidate(null, "ANALYZE schema.tbl;", new StatisticsTarget("SCHEMA", "TBL"));
parseValidate(null, "ANALYZE schema.tbl(a)", new StatisticsTarget("SCHEMA", "TBL", "A"));
parseValidate(null, "ANALYZE schema.tbl(a);", new StatisticsTarget("SCHEMA", "TBL", "A"));
parseValidate(null, "ANALYZE tbl(a)", new StatisticsTarget((String) null, "TBL", "A"));
parseValidate(null, "ANALYZE tbl(a);", new StatisticsTarget((String) null, "TBL", "A"));
parseValidate("SOME_SCHEMA", "ANALYZE tbl, schema.tbl2", new StatisticsTarget((String) null, "TBL"), new StatisticsTarget("SCHEMA", "TBL2"));
parseValidate(null, "ANALYZE tbl(a, b, c)", new StatisticsTarget((String) null, "TBL", "A", "B", "C"));
parseValidate(null, "ANALYZE tbl(a), schema.tbl2(a,B)", new StatisticsTarget((String) null, "TBL", "A"), new StatisticsTarget("SCHEMA", "TBL2", "A", "B"));
assertParseError(null, "ANALYZE p,", "Unexpected end of command");
assertParseError(null, "ANALYZE p()", "Unexpected token: \")\"");
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsTarget in project ignite by apache.
the class SqlParserAnalyzeSelfTest method validate.
/**
* Validate command.
*
* @param cmd Command to validate.
* @param targets Expected targets.
*/
private static void validate(SqlAnalyzeCommand cmd, StatisticsTarget... targets) {
assertEquals(cmd.configurations().size(), targets.length);
Set<StatisticsTarget> cmdTargets = cmd.configurations().stream().map(c -> new StatisticsTarget(c.key(), c.columns().keySet().toArray(new String[0]))).collect(Collectors.toSet());
for (StatisticsTarget target : targets) assertTrue(cmdTargets.contains(target));
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsTarget in project ignite by apache.
the class CommandProcessor method processRefreshStatisticsCommand.
/**
* Process refresh statistics command.
*
* @param cmd Refresh statistics command.
*/
private void processRefreshStatisticsCommand(SqlRefreshStatitsicsCommand cmd) throws IgniteCheckedException {
ctx.security().authorize(SecurityPermission.REFRESH_STATISTICS);
IgniteH2Indexing indexing = (IgniteH2Indexing) ctx.query().getIndexing();
StatisticsTarget[] targets = cmd.targets().stream().map(t -> (t.schema() == null) ? new StatisticsTarget(cmd.schemaName(), t.obj(), t.columns()) : t).toArray(StatisticsTarget[]::new);
indexing.statsManager().refreshStatistics(targets);
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsTarget in project ignite by apache.
the class SqlParserDropStatisticsSelfTest method testDrop.
/**
* Tests for DROP STATISTICS command.
*/
@Test
public void testDrop() {
parseValidate(null, "DROP STATISTICS tbl", new StatisticsTarget((String) null, "TBL"));
parseValidate(null, "DROP STATISTICS tbl;", new StatisticsTarget((String) null, "TBL"));
parseValidate(null, "DROP STATISTICS schema.tbl", new StatisticsTarget("SCHEMA", "TBL"));
parseValidate(null, "DROP STATISTICS schema.tbl;", new StatisticsTarget("SCHEMA", "TBL"));
parseValidate(null, "DROP STATISTICS schema.tbl(a)", new StatisticsTarget("SCHEMA", "TBL", "A"));
parseValidate(null, "DROP STATISTICS schema.tbl(a);", new StatisticsTarget("SCHEMA", "TBL", "A"));
parseValidate(null, "DROP STATISTICS tbl(a)", new StatisticsTarget((String) null, "TBL", "A"));
parseValidate(null, "DROP STATISTICS tbl(a);", new StatisticsTarget((String) null, "TBL", "A"));
parseValidate(null, "DROP STATISTICS tbl(a, b, c)", new StatisticsTarget((String) null, "TBL", "A", "B", "C"));
parseValidate(null, "DROP STATISTICS tbl(a), schema.tbl2(a,B)", new StatisticsTarget((String) null, "TBL", "A"), new StatisticsTarget("SCHEMA", "TBL2", "A", "B"));
assertParseError(null, "DROP STATISTICS p,", "Unexpected end of command");
assertParseError(null, "DROP STATISTICS p()", "Unexpected token: \")\"");
}
Aggregations