Skip to content
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

[CARBONDATA-1738] [PreAgg] Block direct insert/load on pre-aggregate table #1508

Closed
wants to merge 1 commit into from

Conversation

kunal642
Copy link
Contributor

Block load/insert on pre-aggregate table

  • Any interfaces changed?
    No
  • Any backward compatibility impacted?
    No
  • Document update required?
    No
  • Testing done
    Added test case
  • For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.

@@ -212,6 +212,18 @@ object CarbonSession {
ThreadLocalSessionInfo.setCarbonSessionInfo(currentThreadSessionInfo)
}

def threadUnset(key: String): Unit = {
var currentThreadSessionInfo = ThreadLocalSessionInfo.getCarbonSessionInfo
if (currentThreadSessionInfo == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If null then not required to unset

@@ -51,11 +51,39 @@ object LoadPostAggregateListener extends OperationEventListener {
val childDatabaseName = dataMapSchema.getRelationIdentifier.getDatabaseName
val selectQuery = dataMapSchema.getProperties.get("CHILD_SELECT QUERY")
sparkSession.sql(s"insert into $childDatabaseName.$childTableName $selectQuery")
CarbonSession.threadUnset(CarbonCommonConstants.CARBON_INPUT_SEGMENTS +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this unset to finally

val carbonLoadModel = loadEvent.carbonLoadModel
val table = carbonLoadModel.getCarbonDataLoadSchema.getCarbonTable
val carbonSessionInfo = ThreadLocalSessionInfo.getCarbonSessionInfo
val isInternalLoadCall = carbonSessionInfo.getSessionParams.getAll.keySet().asScala
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use specifc parameter instead of using this VALIDATE_CARBON_INPUT_SEGMENTS

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1182/

@CarbonDataQA
Copy link

Build Failed with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1210/

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1215/

* Whether load/insert command is fired internally or by the user.
* Used to block load/insert on pre-aggregate if fired by user
*/
public static final String IS_INTERNAL_LOAD_CALL = "is.internal.load.call";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems no testcase for this option. And the option name should start with carbon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option/property will not be exposed to the user. It will be set by the post load listener to know whether the load is fired by the user or is it an internal call.

Test case is added in TestPreAggregateLoad

@kunal642
Copy link
Contributor Author

retest this please

@CarbonDataQA
Copy link

Build Failed with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1240/

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1288/

@kunal642
Copy link
Contributor Author

retest this please

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1289/

@kunal642 kunal642 force-pushed the block_load_on_preagg branch 2 times, most recently from 955a4a8 to 718a9b1 Compare November 20, 2017 07:53
@CarbonDataQA
Copy link

Build Failed with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1308/

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1313/

@CarbonDataQA
Copy link

Build Failed with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1324/

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1326/

@ravipesala
Copy link
Contributor

SDV Build Fail , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/1784/

@kunal642 kunal642 changed the title [CARBONDATA-1738] Block direct insert/load on pre-aggregate table [CARBONDATA-1738] [PreAgg] Block direct insert/load on pre-aggregate table Nov 21, 2017
@kunal642
Copy link
Contributor Author

@ravipesala Please review

@ravipesala
Copy link
Contributor

retest sdv please

@ravipesala
Copy link
Contributor

SDV Build Fail , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/1801/

@ravipesala
Copy link
Contributor

retest sdv please

s"insert into ${ tableModel.databaseName }.${ tableModel.tableName } $queryString")
val availableLoads = PreAggregateUtil.checkMainTableLoad(parentTable)
if (availableLoads) {
val headers = childSchema.getChildSchema.getListOfColumns.asScala.map(_.getColumnName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move line done

if (availableLoads) {
val headers = childSchema.getChildSchema.getListOfColumns.asScala.map(_.getColumnName)
.mkString(",")
val childDataFrame = sparkSession.sql(new CarbonSpark2SqlParser()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move down after (

val childDataFrame = sparkSession.sql(new CarbonSpark2SqlParser()
.addPreAggLoadFunction(s"${ dataMapSchema.getProperties.get("CHILD_SELECT QUERY") } "))
.drop("preAggLoad")
val headers = dataMapSchema.getChildSchema.getListOfColumns.asScala.map(_.getColumnName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move down

throw new UnsupportedOperationException(
"Cannot insert/load data directly into pre-aggregate table")
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line

@@ -253,8 +260,8 @@ object PreAggregateUtil {
carbonTable.getColumnByName(parentTableName, attr.name).getColumnId,
parentTableName,
parentDatabaseName, parentTableId = parentTableId)
case _ =>
throw new MalformedCarbonCommandException("Un-Supported Aggregation Type")
case a@_ =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep as case others

attr.name + "_sum")(),
Alias(attrExpression
.copy(aggregateFunction = Count(cast),
resultId = NamedExpression.newExprId), attr.name + "_count")())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format it properly

filteredExpressions
.exists {
expr => !expr.name.equalsIgnoreCase("PreAgg") &&
expr.name.equalsIgnoreCase("preAggLoad")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format properly

def addPreAggLoadFunction(sql: String): String = {
addPreAggLoad(new lexical.Scanner(sql.toLowerCase)) match {
case Success(query, _) => query
case _ => throw new MalformedCarbonCommandException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move down line

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1639/

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1641/

@ravipesala
Copy link
Contributor

SDV Build Fail , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/2031/

@kunal642
Copy link
Contributor Author

kunal642 commented Dec 3, 2017

@ravipesala Handled all the review comments

@ravipesala
Copy link
Contributor

SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/2053/

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1664/

@ravipesala
Copy link
Contributor

SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/2055/

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1668/

@ravipesala
Copy link
Contributor

SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/2057/

@CarbonDataQA
Copy link

Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/1670/

@CarbonDataQA
Copy link

Build Success with Spark 2.2, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/400/

@ravipesala
Copy link
Contributor

LGTM

@asfgit asfgit closed this in 5ae596b Dec 4, 2017
jatin9896 pushed a commit to jatin9896/incubator-carbondata that referenced this pull request Jan 5, 2018
anubhav100 pushed a commit to anubhav100/incubator-carbondata that referenced this pull request Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants