Skip to content

Commit

Permalink
Add documentation of #493 and #496
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric L. Charlier committed Jul 2, 2019
1 parent c0029a5 commit 806cf90
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions _documentation/primitive-result-set.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ More info about [shared-dataset](../docs/shared-dataset)

You can also define an alteration to the result-set. For the moment, three kinds of alterations are supported by NBi:

* [rename](../resultset-alterations/#renaming)
* [filter](../resultset-rows-count-advanced/#filter).
* [convert](../resultset-alterations/#converts)
* [transform](../transform-column/)
Expand Down
16 changes: 14 additions & 2 deletions _documentation/primitive-scalar.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,24 @@ A *text* scalar can be dynamically evaluated based on one or several variables a

Using the previous notation, if the value of *myDate* is *25th October 2018* then the filename *File_2018.csv* will be considered for loading the result-set.

In case the variable is a numeric or dateTime, it can be useful to format it. This formatting must be specified after a column (```:```).
A number of types support format strings, including *numeric* type (both [standard](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings?view=netframework-4.8) and [custom](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings?view=netframework-4.8) format strings), but also dateTime (both [standard](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings?view=netframework-4.8) and [custom](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings?view=netframework-4.8) format strings). This formatting must be specified after a column (```:```).

{% highlight xml %}
<parameter name="myParam">~File_{@myDate:yyyy}_{@myDate:MM}.csv</parameter>
{% endhighlight %}

Using the previous notation, if the value of *myDate* is *25th October 2018* then the filename *File_2018_10.csv* will be considered for loading the result-set.

The formatting syntax is the one supported by .Net and explained in MSDN for the [numerics](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings) and [dateTimes](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings)
#### Formatting and inline transformations

It's possible to combine formatting and inline transformations. The following example will calculate the previous month and this value will be used during the formatting. Supposing the value of *myDate* is *25th October 2018* then the filename *File_201809.csv* will be considered for loading the following result-set.

{% highlight xml %}
<parameter name="myParam">~File_{@myDate | dateTime-to-previous-month:yyyyMM}.csv</parameter>
{% endhighlight %}

It's also possible to apply an inline transformation to the result of a formatting operation. The following example will calculate the length of the formatted rendering of the variable *myNumeric*. Based on a value of *100.2*, the rendering will be *100.20* and its length will be *6*.

{% highlight xml %}
<parameter name="myParam">~{@myNumeric:##.00} | text-to-length</parameter>
{% endhighlight %}
18 changes: 18 additions & 0 deletions _documentation/resultset-alterations.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ permalink: /docs/resultset-alterations/
---
Using the [new syntax](../syntax-2-0/), it's possible to define alterations on a result-set. It gives you the possibility to alter the result-set without modifying the query retrieving it. It's especially useful when the alteration is complex to write in the query language or when it's not possible to modify the query (stored procedure, assembly, report-dataset ...). The two alterations supported by NBi are the filters and the converts.

## Renamings

This alteration is useful when you want to rename a column. This kind of alteration is usually not needed except or can be handled by the query but when dealing with flat files, it could save you! To identify the original column to be renamed, you can use a column identifier of type ordinal such as *#3* or of type name such as *[myColumn]*. The new name of this column is a [scalar](../primitive-scalar/), it means that you can use a literal value but also variables, native transformations or formatting.

In the following example, the first column is renamed *keyField* and the column named *f1* is renamed based on the content of the variable *newName* upper-cased.

{% highlight xml %}
<result-set>
<query>
select 'a' as f0, 'FOO' as f1, null as f2 union all select 'B', 'bar', 'quark'
</query>
<alteration>
<rename identifier="#0" new-name="keyField"/>
<rename identifier="[f1]" new-name="@newName | text-to-upper"/>
</alteration>
</result-set>
{% endhighlight %}

## Filters

See [filters for row-count](../resultset-rows-count-advanced/#filter)
Expand Down

0 comments on commit 806cf90

Please sign in to comment.