use of org.apache.ignite.internal.processors.query.stat.StatisticsTarget in project ignite by apache.
the class SqlParserRefreshStatisticsSelfTest method testRefresh.
/**
* Tests for REFRESH STATISTICS command.
*/
@Test
public void testRefresh() {
parseValidate(null, "REFRESH STATISTICS tbl", new StatisticsTarget((String) null, "TBL"));
parseValidate(null, "REFRESH STATISTICS tbl;", new StatisticsTarget((String) null, "TBL"));
parseValidate(null, "REFRESH STATISTICS schema.tbl", new StatisticsTarget("SCHEMA", "TBL"));
parseValidate(null, "REFRESH STATISTICS schema.tbl;", new StatisticsTarget("SCHEMA", "TBL"));
parseValidate(null, "REFRESH STATISTICS schema.tbl(a)", new StatisticsTarget("SCHEMA", "TBL", "A"));
parseValidate(null, "REFRESH STATISTICS schema.tbl(a);", new StatisticsTarget("SCHEMA", "TBL", "A"));
parseValidate(null, "REFRESH STATISTICS tbl(a)", new StatisticsTarget((String) null, "TBL", "A"));
parseValidate(null, "REFRESH STATISTICS tbl(a);", new StatisticsTarget((String) null, "TBL", "A"));
parseValidate(null, "REFRESH STATISTICS tbl(a, b, c)", new StatisticsTarget((String) null, "TBL", "A", "B", "C"));
parseValidate(null, "REFRESH STATISTICS tbl(a), schema.tbl2(a,B)", new StatisticsTarget((String) null, "TBL", "A"), new StatisticsTarget("SCHEMA", "TBL2", "A", "B"));
assertParseError(null, "REFRESH STATISTICS p,", "Unexpected end of command");
assertParseError(null, "REFRESH STATISTICS p()", "Unexpected token: \")\"");
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsTarget in project ignite by apache.
the class SqlAnalyzeCommand method parse.
/**
* {@inheritDoc}
*/
@Override
public SqlCommand parse(SqlLexer lex) {
while (true) {
SqlQualifiedName tblQName = parseQualifiedIdentifier(lex);
String[] cols = parseColumnList(lex, true);
Map<String, String> params = parseParams(lex);
StatisticsTarget target = new StatisticsTarget(tblQName.schemaName(), tblQName.name(), cols);
configs.add(buildConfig(target, params));
if (tryEnd(lex))
return this;
}
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsTarget in project ignite by apache.
the class CommandProcessor method processDropStatisticsCommand.
/**
* Process drop statistics command.
*
* @param cmd Drop statistics command.
*/
private void processDropStatisticsCommand(SqlDropStatisticsCommand cmd) throws IgniteCheckedException {
ctx.security().authorize(SecurityPermission.CHANGE_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().dropStatistics(targets);
}
Aggregations