-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added better support for XML types into Flow (#474)
* Added better support for XML types into Flow * adjustments after code review
- Loading branch information
1 parent
8c704b1
commit 57666bf
Showing
31 changed files
with
1,145 additions
and
406 deletions.
There are no files selected for viewing
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,104 @@ | ||
<Salaries> | ||
<Month name="January"> | ||
<Department name="HR"> | ||
<TotalSalary>71883</TotalSalary> | ||
</Department> | ||
<Department name="Engineering"> | ||
<TotalSalary>192644</TotalSalary> | ||
</Department> | ||
<Department name="Finance"> | ||
<TotalSalary>174187</TotalSalary> | ||
</Department> | ||
<Department name="Marketing"> | ||
<TotalSalary>179932</TotalSalary> | ||
</Department> | ||
<Department name="Sales"> | ||
<TotalSalary>52056</TotalSalary> | ||
</Department> | ||
</Month> | ||
<Month name="February"> | ||
<Department name="HR"> | ||
<TotalSalary>102342</TotalSalary> | ||
</Department> | ||
<Department name="Engineering"> | ||
<TotalSalary>111102</TotalSalary> | ||
</Department> | ||
<Department name="Finance"> | ||
<TotalSalary>81938</TotalSalary> | ||
</Department> | ||
<Department name="Marketing"> | ||
<TotalSalary>132202</TotalSalary> | ||
</Department> | ||
<Department name="Sales"> | ||
<TotalSalary>173225</TotalSalary> | ||
</Department> | ||
</Month> | ||
<Month name="March"> | ||
<Department name="HR"> | ||
<TotalSalary>79619</TotalSalary> | ||
</Department> | ||
<Department name="Engineering"> | ||
<TotalSalary>99387</TotalSalary> | ||
</Department> | ||
<Department name="Finance"> | ||
<TotalSalary>198847</TotalSalary> | ||
</Department> | ||
<Department name="Marketing"> | ||
<TotalSalary>50550</TotalSalary> | ||
</Department> | ||
<Department name="Sales"> | ||
<TotalSalary>98212</TotalSalary> | ||
</Department> | ||
</Month> | ||
<Month name="April"> | ||
<Department name="HR"> | ||
<TotalSalary>69721</TotalSalary> | ||
</Department> | ||
<Department name="Engineering"> | ||
<TotalSalary>151826</TotalSalary> | ||
</Department> | ||
<Department name="Finance"> | ||
<TotalSalary>158168</TotalSalary> | ||
</Department> | ||
<Department name="Marketing"> | ||
<TotalSalary>111872</TotalSalary> | ||
</Department> | ||
<Department name="Sales"> | ||
<TotalSalary>172334</TotalSalary> | ||
</Department> | ||
</Month> | ||
<Month name="May"> | ||
<Department name="HR"> | ||
<TotalSalary>174220</TotalSalary> | ||
</Department> | ||
<Department name="Engineering"> | ||
<TotalSalary>164086</TotalSalary> | ||
</Department> | ||
<Department name="Finance"> | ||
<TotalSalary>104257</TotalSalary> | ||
</Department> | ||
<Department name="Marketing"> | ||
<TotalSalary>105817</TotalSalary> | ||
</Department> | ||
<Department name="Sales"> | ||
<TotalSalary>145490</TotalSalary> | ||
</Department> | ||
</Month> | ||
<Month name="June"> | ||
<Department name="HR"> | ||
<TotalSalary>127383</TotalSalary> | ||
</Department> | ||
<Department name="Engineering"> | ||
<TotalSalary>52592</TotalSalary> | ||
</Department> | ||
<Department name="Finance"> | ||
<TotalSalary>71732</TotalSalary> | ||
</Department> | ||
<Department name="Marketing"> | ||
<TotalSalary>165083</TotalSalary> | ||
</Department> | ||
<Department name="Sales"> | ||
<TotalSalary>85138</TotalSalary> | ||
</Department> | ||
</Month> | ||
</Salaries> |
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,10 @@ | ||
<root> | ||
<items> | ||
<item><id>1</id></item> | ||
<item><id>2</id></item> | ||
<item><id>3</id></item> | ||
<item><id>4</id></item> | ||
<item><id>5</id></item> | ||
<item><id>6</id></item> | ||
</items> | ||
</root> |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Flow\ETL\DSL\To; | ||
use Flow\ETL\DSL\XML; | ||
use Flow\ETL\Flow; | ||
|
||
require __DIR__ . '/../../../bootstrap.php'; | ||
|
||
print "Reading XML dataset...\n"; | ||
|
||
(new Flow()) | ||
->read(XML::from(__FLOW_DATA__ . '/simple_items.xml', 'root/items/item')) | ||
->write(To::output(false)) | ||
->run(); |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use function Flow\ETL\DSL\ref; | ||
use Flow\ETL\DSL\To; | ||
use Flow\ETL\DSL\XML; | ||
use Flow\ETL\Flow; | ||
use Flow\ETL\GroupBy\Aggregation; | ||
|
||
require __DIR__ . '/../../../bootstrap.php'; | ||
|
||
print "Reading XML dataset...\n"; | ||
|
||
(new Flow()) | ||
->read(XML::from(__FLOW_DATA__ . '/salaries.xml')) | ||
->withEntry('months', ref('row')->xpath('/Salaries/Month')) | ||
->withEntry('month', ref('months')->expand()) | ||
->withEntry('month_name', ref('month')->domNodeAttribute('name')) | ||
->withEntry('departments', ref('month')->xpath('/Month/Department')) | ||
->withEntry('department', ref('departments')->expand()) | ||
->withEntry('department_name', ref('department')->domNodeAttribute('name')) | ||
->withEntry('department_salary', ref('department')->xpath('/Department/TotalSalary')->domNodeValue()) | ||
->drop('row', 'months', 'month', 'departments', 'department') | ||
->groupBy(ref('month_name')) | ||
->aggregate(Aggregation::sum(ref('department_salary'))) | ||
->rename('department_salary_sum', 'total_monthly_salaries') | ||
->write(To::output(false)) | ||
->run(); |
Oops, something went wrong.