korlov42 commented on code in PR #1101:
URL: https://github.com/apache/ignite-3/pull/1101#discussion_r974936804
##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/PlannerTest.java:
##########
@@ -860,6 +866,81 @@ public void correctPlanningWithOrToUnion() throws
Exception {
assertPlan(sql, publicSchema, (k) -> true);
}
+ @Test
+ public void checkTableHintsHandling() throws Exception {
+ IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
+
+ TestTable person = new TestTable(
+ new RelDataTypeFactory.Builder(f)
+ .add("PK", f.createJavaType(Integer.class))
+ .add("ORG_ID", f.createJavaType(Integer.class))
+ .build()) {
+
+ @Override public IgniteDistribution distribution() {
+ return IgniteDistributions.affinity(0, "ignored", "ignored");
+ }
+ };
+
+ TestTable company = new TestTable(
+ new RelDataTypeFactory.Builder(f)
+ .add("PK", f.createJavaType(Integer.class))
+ .add("ID", f.createJavaType(Integer.class))
+ .build()) {
+
+ @Override public IgniteDistribution distribution() {
+ return IgniteDistributions.affinity(0, "ignored", "ignored");
+ }
+ };
+
+ IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
+
+ publicSchema.addTable("PERSON", person);
+ publicSchema.addTable("COMPANY", company);
Review Comment:
```suggestion
IgniteSchema publicSchema = createSchema(
createTable("PERSON", IgniteDistributions.affinity(0,
"ignored", "ignored"),
"PK", Integer.class, "ORG_ID", Integer.class
),
createTable("COMPANY", IgniteDistributions.affinity(0,
"ignored", "ignored"),
"PK", Integer.class, "ID", Integer.class
)
);
```
##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/PlannerTest.java:
##########
@@ -860,6 +866,81 @@ public void correctPlanningWithOrToUnion() throws
Exception {
assertPlan(sql, publicSchema, (k) -> true);
}
+ @Test
+ public void checkTableHintsHandling() throws Exception {
+ IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
+
+ TestTable person = new TestTable(
+ new RelDataTypeFactory.Builder(f)
+ .add("PK", f.createJavaType(Integer.class))
+ .add("ORG_ID", f.createJavaType(Integer.class))
+ .build()) {
+
+ @Override public IgniteDistribution distribution() {
+ return IgniteDistributions.affinity(0, "ignored", "ignored");
+ }
+ };
+
+ TestTable company = new TestTable(
+ new RelDataTypeFactory.Builder(f)
+ .add("PK", f.createJavaType(Integer.class))
+ .add("ID", f.createJavaType(Integer.class))
+ .build()) {
+
+ @Override public IgniteDistribution distribution() {
+ return IgniteDistributions.affinity(0, "ignored", "ignored");
+ }
+ };
+
+ IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
+
+ publicSchema.addTable("PERSON", person);
+ publicSchema.addTable("COMPANY", company);
+
+ SchemaPlus schema = createRootSchema(false)
+ .add("PUBLIC", publicSchema);
+
+ String sql = "SELECT * FROM person /*+ use_index(ORG_ID), extra */ t1
JOIN company /*+ use_index(ID) */ t2 ON t1.org_id = t2.id";
+
+ PlanningContext ctx = PlanningContext.builder()
+ .parentContext(BaseQueryContext.builder()
+ .logger(log)
+ .frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
+ .defaultSchema(schema)
+ .sqlToRelConverterConfig(FRAMEWORK_CONFIG
+ .getSqlToRelConverterConfig()
+
.withHintStrategyTable(HintStrategyTable.builder()
+ .hintStrategy("use_index",
(hint, rel) -> true)
+ .hintStrategy("extra", (hint,
rel) -> true)
+ .build()
+ ))
+ .build())
+ .build())
+ .query(sql)
+ .build();
+
+ IgniteRel plan = physicalPlan(sql, ctx);
+
+ Map<String, Integer> hintsMap = new HashMap<>();
+
+ plan.accept(new RelShuttleImpl() {
Review Comment:
please take a look at
`org.apache.ignite.internal.sql.engine.planner.AbstractPlannerTest#assertPlan`.
You may find it more convenient
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]