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

Improve ETLv2 query debug #46

Merged
merged 7 commits into from
Feb 3, 2017
Merged

Conversation

smgallo
Copy link
Contributor

@smgallo smgallo commented Feb 2, 2017

Improve ETLv2 query debuging

Description

Augment Loggable::logAndThrowException() to accept a list of options and customize messages based on these options. This allowed us to merge Loggable::logAndThrowSqlException() into Loggable::logAndThrowException() and improve the display of SQL in debug mode.

Also display the DataEndpoint associated with every query now and fix phpcs style issues.

Note that commits 216aa24, 8bfbcac, 729b1da were from a local merge and have already been merged in #45.

Motivation and Context

ETL is getting more complex pulling data from multiple databases, schemas, and files. It is important when debugging to know the queries being generated and the databases and schemas (DataEndpoints) that they are being run against.

Tests performed

Ran the following ETLv2 pipelines: xdcdb-jobs (with and without aggregation binning), test-suite, resource-allocations. These test the following actions:

  • Database Ingestor
  • Update ingestor
  • Jobs Aggregator
  • Simple Aggregator
  • Execute SQL
  • MySQL, Postgres, JSON data endpoints

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project as found in the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

- Augment Loggable::logAndThrowException() to customize message based on optional parameters
- Merge Loggable::logAndThrowSqlException() into Loggable::logAndThrowException()
- Improve display of SQL in debug mode
- Display DataEndpoint associated with every query now that ETL is getting more complex
@smgallo smgallo added the enhancement Enhancement of the functionality of an existing feature label Feb 2, 2017
@smgallo smgallo added this to the v6.6.0 milestone Feb 2, 2017
case 'regex':
if ( false === preg_match($directive->format, "test") ) {
$msg = "Invalid regex format '{$directive->format}' for key '$key'";
$this->logAndThrowException($msg);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to set the error message to a variable or should we just pass it into the function call?

}
break;
default:
$msg = "Unsupported transform type '{$directive->type}' for key '$key'";
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to set the error message to a variable or should we just pass it into the function call?

$msg = "Invalid regex format '{$directive->format}' for key '$key'";
case 'regex':
if ( false === preg_match($directive->format, "test") ) {
$msg = "Invalid regex format '{$directive->format}' for key '$key'";
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to set the error message to a variable or should we just pass it into the function call?

}
break;
default:
$msg = "Unsupported transform type '{$directive->type}' for key '$key'";
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to set the error message to a variable or should we just pass it into the function call?

$matches = null;
$matched = preg_match($directive->format, $value, $matches);
if ( false === $matched ) {
$msg = "Error transforming regex '{$directive->format}'";
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to set the error message to a variable or should we just pass it into the function call?

case 'regex':
$matched = preg_match($directive->format, $value);
if ( 0 === $matched ) {
$msg = "Failed {$directive->type} ({$directive->format}) verification for '$value'";
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to set the error message to a variable or should we just pass it into the function call?

$sql = "UPDATE " . $this->etlDestinationTable->getFullName() . " SET "
. implode(
", ",
array_map(
Copy link
Contributor

Choose a reason for hiding this comment

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

could/should we turn these two into a function? pass the connector (', ' or ' AND ' ) and the values?

@smgallo
Copy link
Contributor Author

smgallo commented Feb 3, 2017

Addressed @plessbd review comments. The change to UpdateIngestor.php is out of the scope of this pull request but there is a plan to deal with that by moving query construction tools into their own utility class.

@smgallo smgallo merged commit 4ab1b8d into ubccr:xdmod6.6 Feb 3, 2017
@smgallo smgallo deleted the etl/improve-query-debug branch February 3, 2017 14:35
ryanrath pushed a commit to ryanrath/xdmod that referenced this pull request Apr 27, 2017
* Make all aggregation period data available as bind parameters to query

* Fix phpcs issues

* Addressed code review comments

* Improve ETLv2 debugging messages
- Augment Loggable::logAndThrowException() to customize message based on optional parameters
- Merge Loggable::logAndThrowSqlException() into Loggable::logAndThrowException()
- Improve display of SQL in debug mode
- Display DataEndpoint associated with every query now that ETL is getting more complex

* Fix phpcs issues

* Address @plessb code review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of the functionality of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants