Skip to content

Commit 3833146

Browse files
committed
pbix: README
1 parent 204f8b3 commit 3833146

File tree

4 files changed

+124
-1
lines changed

4 files changed

+124
-1
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# langauge-powerquery
2+
Tools for working with and analyzing PowerQuery (M Language) scripts
3+
- Haskell data structures and AST ([language-powerquery-ast])
4+
- Haskell lexer/parser/printer ([language-powerquery])
5+
- PowerBI `.pbix` file reader ([pbix])
6+
- Example IHaskell (Jupyter) [notebooks]
7+
8+
# Build
9+
- [Install Nixpkgs]
10+
- `make` (executable)
11+
~~~ shell
12+
12:52 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ make
13+
nix-build --cores 0 -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/19.03.tar.gz
14+
/nix/store/3lzlivfyy7cqnxw0q594amsj94yswk43-powerquery-env
15+
12:52 barak@berkos:~/Development/atidot/language-powerquery/build (master) $
16+
~~~
17+
- `make` (Docker)
18+
- TODO:
19+
20+
- `make` (notebook) - build and run IHaskell (Jupyter) server
21+
~~~ shell
22+
13:36 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ make notebook
23+
nix-shell --cores 0 -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/19.03.tar.gz -A env notebook.nix --command "jupyter lab --notebook-dir=../examples/"
24+
[W 13:37:07.009 LabApp] JupyterLab server extension not enabled, manually loading...
25+
[I 13:37:07.014 LabApp] JupyterLab extension loaded from /nix/store/wp1ddiscc9bha9gsf4k73mb0lcxcjbi2-python3.7-jupyterlab-0.35.4/lib/python3.7/site-packages/jupyterlab
26+
[I 13:37:07.015 LabApp] JupyterLab application directory is /nix/store/g22w2r0a6vzax71np2fzpxwzpx0wq1kf-python3.7-jupyterlab-0.35.4/share/jupyter/lab
27+
[I 13:37:07.017 LabApp] Serving notebooks from local directory: /home/barak/Development/atidot/language-powerquery/examples
28+
[I 13:37:07.017 LabApp] The Jupyter Notebook is running at:
29+
[I 13:37:07.017 LabApp] http://localhost:8888/?token=9b2938f88185aba667fd5858051083843361becd94208625
30+
[I 13:37:07.018 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
31+
[C 13:37:07.130 LabApp]
32+
33+
Copy/paste this URL into your browser when you connect for the first time,
34+
to login with a token:
35+
http://localhost:8888/?token=9b2938f88185aba667fd5858051083843361becd94208625
36+
[I 13:37:07.300 LabApp] Accepting one-time-token-authenticated connection from ::1
37+
~~~
38+
39+
[language-powerquery-ast]: https://github.com/Atidot/language-powerquery/tree/master/language-powerquery-ast
40+
[language-powerquery]: https://github.com/Atidot/language-powerquery/tree/master/language-powerquery
41+
[pbix]: https://github.com/Atidot/language-powerquery/tree/master/pbix
42+
[notebooks]: https://github.com/Atidot/language-powerquery/tree/master/examples
43+
[Install Nixpkgs]: https://nixos.org/nix/download.html
44+

language-powerquery/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
11
# language-powerquery
22
PowerQuery (M Language) Parser
3+
- Lexer ([alex])
4+
- Parser [happy])
5+
- Pretty Printer
6+
7+
## Specification
8+
- [Power Query M Formula Language Specification PDF]
9+
- Code follows specification closely
10+
![alt text][spec_vs_code]
11+
12+
13+
## TODO
14+
15+
[Power Query M Formula Language Specification PDF]: https://docs.microsoft.com/en-us/powerquery-m/power-query-m-language-specification
16+
[spec_vs_code]: raw/spec_vs_code.png
17+
[alex]: https://github.com/simonmar/alex
18+
[happy]: https://github.com/simonmar/happy
199 KB
Loading

pbix/README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,65 @@
11
# pbix
2-
PowerBI Coder/Decoder
2+
PowerBI `.pbix` file coder/decoder
3+
4+
5+
# [Build]
6+
7+
# CLI
8+
### Print a formula (M script) from DataMashup/Formulas
9+
~~~ shell
10+
12:55 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m
11+
section Section1;
12+
13+
shared iris = let
14+
Source = Csv.Document(File.Contents("\\VBOXSVR\Shared\PowerBI\iris.csv"),[Delimiter=",", Columns=5, Encoding=1252, QuoteStyle=QuoteStyle.None]),
15+
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
16+
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"sepal_length", type number}, {"sepal_width", type number}, {"petal_length", type number}, {"petal_width", type number}, {"species", type text}})
17+
in
18+
#"Changed Type";
19+
12:55 barak@berkos:~/Development/atidot/language-powerquery/build (master) $
20+
~~~
21+
22+
### Print the Haskell AST (Abstract Syntax Tree) of a formula
23+
~~~ shell
24+
12:56 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m -x | head -c 400
25+
SectionDocument (Section {_section_attributes = Nothing, _section_name = Just (RegularI "Section1"), _section_members = Just [SectionMember {_sectionMember_attributes = Nothing, _sectionMember_shared = True, _sectionMember_name = Reg
26+
ularI "iris", _sectionMember_expression = LetE (LetExpression {_letExpression_variableList = [Variable {_variable_name = RegularI "Source", _variable_expression = Logi
27+
12:57 barak@berkos:~/Development/atidot/language-powerquery/build
28+
~~~
29+
30+
### Print the AST as a JSON
31+
- ([iris dataset])
32+
~~~ shell
33+
12:58 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m -x -j | head -c 1000
34+
{"tag":"SectionDocument","contents":{"_section_attributes":null,"_section_name":{"tag":"RegularI","contents":"Section1"},"_section_members":[{"_sectionMember_expression":{"tag":"LetE","contents":{"_letExpression_expression":{"tag":"L
35+
ogicalE","contents":{"tag":"And_OE","contents":{"tag":"Is_LAE","contents":{"tag":"As_IE","contents":{"tag":"EqualityAE","contents":{"tag":"RelationalEE","contents":{"tag":"AdditiveRE","contents":{"tag":"MultiplicativeAE","contents":{
36+
"tag":"MetadataME","contents":{"_metadataExpression_second":null,"_metadataExpression_annotation":[],"_metadataExpression_first":{"tag":"UnaryType","contents":{"tag":"Primary_TE","contents":{"tag":"FieldAccessPE","contents":{"_implic
37+
itTargetProjection_annotation":[],"tag":"ImplicitTargetProjection","_implicitTargetProjection_identifier":{"tag":"QuotedI","contents":"#\"Changed Type\""}}}}}}}}}}}}}}},"_letExpression_variableList":[{"_variable_annotation":[],"_vari
38+
able_expression":{"tag":"LogicalE","contents":{"tag":"And_OE","conte
39+
12:58 barak@berkos:~/Development/atidot/language-powerquery/build (master) $
40+
~~~
41+
42+
### Print all String Literals (using [jq])
43+
~~~ shell
44+
12:25 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m -x -j | jq -c 'paths as $path | select(getpath($path) == "String
45+
L") | getpath($path[:-1]) | .contents'
46+
"\"\\\\VBOXSVR\\Shared\\PowerBI\\iris.csv\""
47+
"\",\""
48+
"\"sepal_length\""
49+
"\"sepal_width\""
50+
"\"petal_length\""
51+
"\"petal_width\""
52+
"\"species\""
53+
~~~
54+
55+
### Print all Variables names (using [jq])
56+
~~~ shell
57+
12:47 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m -x -j | jq 'paths as $path | select($path[-1] == "_variable_name") | getpath($path) | .contents'
58+
"Source"
59+
"#\"Promoted Headers\""
60+
"#\"Changed Type\""
61+
~~~
62+
63+
[jq]: https://stedolan.github.io/jq/
64+
[Build]: https://github.com/Atidot/language-powerquery#Build
65+
[iris dataset]: https://www.kaggle.com/arshid/iris-flower-dataset

0 commit comments

Comments
 (0)