-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move analyze skipping index rules to config #288
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
48 changes: 48 additions & 0 deletions
48
flint-spark-integration/src/main/resources/skipping_index_recommendation.conf
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,48 @@ | ||
recommendation { | ||
data_type_rules { | ||
PARTITION { | ||
skipping_type = PARTITION, | ||
reason = "PARTITION data structure is recommended for partition columns" | ||
}, | ||
BooleanType { | ||
skipping_type = VALUE_SET, | ||
reason = "VALUE_SET data structure is recommended for BooleanType columns" | ||
}, | ||
IntegerType { | ||
skipping_type = MIN_MAX, | ||
reason = "MIN_MAX data structure is recommended for IntegerType columns" | ||
}, | ||
LongType { | ||
skipping_type = MIN_MAX, | ||
reason = "MIN_MAX data structure is recommended for LongType columns" | ||
}, | ||
ShortType { | ||
skipping_type = MIN_MAX, | ||
reason = "MIN_MAX data structure is recommended for ShortType columns" | ||
}, | ||
DateType { | ||
skipping_type = BLOOM_FILTER, | ||
reason = "BLOOM_FILTER data structure is recommended for DateType columns" | ||
}, | ||
TimestampType { | ||
skipping_type = BLOOM_FILTER, | ||
reason = "BLOOM_FILTER data structure is recommended for TimestampType columns" | ||
}, | ||
StringType { | ||
skipping_type = BLOOM_FILTER, | ||
reason = "BLOOM_FILTER data structure is recommended for StringType columns" | ||
}, | ||
VarcharType { | ||
skipping_type = BLOOM_FILTER, | ||
reason = "BLOOM_FILTER data structure is recommended for VarcharType columns" | ||
}, | ||
CharType { | ||
skipping_type = BLOOM_FILTER, | ||
reason = "BLOOM_FILTER data structure is recommended for CharType columns" | ||
}, | ||
StructType { | ||
skipping_type = BLOOM_FILTER, | ||
reason = "BLOOM_FILTER data structure is recommended for StructType columns" | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -7,27 +7,16 @@ package org.opensearch.flint.spark.skipping.recommendations | |
|
||
import scala.collection.mutable.ArrayBuffer | ||
|
||
import org.opensearch.flint.spark.skipping.FlintSparkSkippingStrategy.SkippingKind.{BLOOM_FILTER, MIN_MAX, PARTITION, VALUE_SET} | ||
import com.typesafe.config.{Config, ConfigFactory} | ||
|
||
import org.apache.spark.sql.{Row, SparkSession} | ||
import org.apache.spark.sql.flint.{loadTable, parseTableName} | ||
|
||
class DataTypeSkippingStrategy extends AnalyzeSkippingStrategy { | ||
|
||
val rules = Map( | ||
"PARTITION" -> (PARTITION.toString, "PARTITION data structure is recommended for partition columns"), | ||
"BooleanType" -> (VALUE_SET.toString, "VALUE_SET data structure is recommended for BooleanType columns"), | ||
"IntegerType" -> (MIN_MAX.toString, "MIN_MAX data structure is recommended for IntegerType columns"), | ||
"LongType" -> (MIN_MAX.toString, "MIN_MAX data structure is recommended for LongType columns"), | ||
"ShortType" -> (MIN_MAX.toString, "MIN_MAX data structure is recommended for ShortType columns"), | ||
"DateType" -> (BLOOM_FILTER.toString, "BLOOM_FILTER data structure is recommended for DateType columns"), | ||
"TimestampType" -> (BLOOM_FILTER.toString, "BLOOM_FILTER data structure is recommended for TimestampType columns"), | ||
"StringType" -> (BLOOM_FILTER.toString, "BLOOM_FILTER data structure is recommended for StringType columns"), | ||
"VarcharType" -> (BLOOM_FILTER.toString, "BLOOM_FILTER data structure is recommended for VarcharType columns"), | ||
"CharType" -> (BLOOM_FILTER.toString, "BLOOM_FILTER data structure is recommended for CharType columns"), | ||
"StructType" -> (BLOOM_FILTER.toString, "BLOOM_FILTER data structure is recommended for StructType columns")) | ||
|
||
override def analyzeSkippingIndexColumns(tableName: String, spark: SparkSession): Seq[Row] = { | ||
val rules: Config = ConfigFactory.load("skipping_index_recommendation.conf") | ||
|
||
val (catalog, ident) = parseTableName(spark, tableName) | ||
val table = loadTable(catalog, ident).getOrElse( | ||
throw new IllegalStateException(s"Table $tableName is not found")) | ||
|
@@ -48,14 +37,16 @@ class DataTypeSkippingStrategy extends AnalyzeSkippingStrategy { | |
result += Row( | ||
field.name, | ||
field.dataType.typeName, | ||
rules("PARTITION")._1, | ||
rules("PARTITION")._2) | ||
} else if (rules.contains(field.dataType.toString)) { | ||
rules.getString("recommendation.data_type_rules.PARTITION.skipping_type"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract util method to avoid appending string in different place? |
||
rules.getString("recommendation.data_type_rules.PARTITION.reason")) | ||
} else if (rules.hasPath("recommendation.data_type_rules." + field.dataType.toString)) { | ||
result += Row( | ||
field.name, | ||
field.dataType.typeName, | ||
rules(field.dataType.toString)._1, | ||
rules(field.dataType.toString)._2) | ||
rules.getString( | ||
"recommendation.data_type_rules." + field.dataType.toString + ".skipping_type"), | ||
rules.getString( | ||
"recommendation.data_type_rules." + field.dataType.toString + ".reason")) | ||
} | ||
} | ||
result | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add missing Javadoc on new class, interface and public methods?