Skip to content

Commit

Permalink
Merge branch 'dbis-uibk:development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaiola authored Jul 26, 2022
2 parents 70f85c0 + 51acdc9 commit 709d3c1
Show file tree
Hide file tree
Showing 21 changed files with 1,284 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A relational algebra calculator
* Use `yarn build` to create release build in the `dist` folder
* Copy the content of your `dist` folder somewhere outside of the repository
* Checkout the branch `gh-pages`
* Remove everything there and pase content of the former `dist` folder
* Remove everything there and paste content of the former `dist` folder
* Push to github (the person doing this must be an administrator of the project)

## Contributions
Expand Down
8 changes: 6 additions & 2 deletions src/calc2/components/editorBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@ export class EditorBase extends React.Component<Props, State> {
try {
const hintsFromLinter = this.props.linterFunction(this, editor, text);


if (hintsFromLinter.length === 0 && this.hinterCache.hintsFromLinter.length === 0) {
// no hint recreation needed
}
Expand All @@ -1125,7 +1126,7 @@ export class EditorBase extends React.Component<Props, State> {
}
catch (e) {
const found = [];

const error = EditorBase._generateErrorFromException(e, 0, 0);
const messageWithoutHtml = $('<span>').append(error.message).text();

Expand Down Expand Up @@ -1286,6 +1287,7 @@ export class EditorBase extends React.Component<Props, State> {
};
if (selectionOnly !== true) { // execute whole text
query = editor.getValue();

}
else { // execute selection
query = editor.getDoc().getSelection();
Expand Down Expand Up @@ -1344,6 +1346,7 @@ export class EditorBase extends React.Component<Props, State> {
return `<span class="math">${String.fromCharCode(parseInt(group0.substr(2), 16))}</span>`;
});


// try to get position information from error
let location = null;

Expand Down Expand Up @@ -1380,6 +1383,7 @@ export class EditorBase extends React.Component<Props, State> {
*/
static buildTranslatedPegJsMessage(expected: PEG.ExpectedItem[], found: string) {
function cleanupExpected(expected: PEG.ExpectedItem[]) {

let i = 1;

expected.sort((a, b) => {
Expand Down Expand Up @@ -1433,6 +1437,7 @@ export class EditorBase extends React.Component<Props, State> {
}

const expectedDescriptions = new Array(expected.length);

// expectedDesc, foundDesc, i;

for (let i = 0; i < expected.length; i++) {
Expand All @@ -1446,7 +1451,6 @@ export class EditorBase extends React.Component<Props, State> {
);

const foundDesc = found ? `"${stringEscape(found)}"` : t('editor.pegjs-error.end-of-input');

return t('editor.pegjs-error.expected-found', { expected: expectedDesc, found: foundDesc });
}

Expand Down
2 changes: 1 addition & 1 deletion src/calc2/components/editorRelalg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class EditorRelalg extends React.Component<Props, State> {
label: '→',
onClick: this.replaceText,
tooltipTitle: 'calc.editors.ra.toolbar.right-arrow',
tooltip: 'calc.editors.ra.toolbar.right-arrow',
tooltip: 'calc.editors.ra.toolbar.right-arrow-content',
},
{
label: 'τ',
Expand Down
4 changes: 4 additions & 0 deletions src/calc2/components/editorSql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class EditorSql extends React.Component<Props> {
execFunction={(self: EditorBase, text: string, offset) => {
const ast = parseSQLSelect(text);
replaceVariables(ast, relations);


if (ast.child === null) {
if (ast.assignments.length > 0) {
Expand All @@ -76,8 +77,10 @@ export class EditorSql extends React.Component<Props> {


const root = relalgFromSQLAstRoot(ast, relations);

if (root) {
root.check();


self.historyAddEntry(text);

Expand All @@ -99,6 +102,7 @@ export class EditorSql extends React.Component<Props> {
linterFunction={(self: EditorBase, editor: CodeMirror.Editor, text: string) => {
const hints = [];


const ast = parseSQLSelect(text);
replaceVariables(ast, relations);

Expand Down
5 changes: 5 additions & 0 deletions src/calc2/components/raTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Popover } from 'calc2/components/popover';
import classNames from 'classnames';
import { RANode, RANodeBinary, RANodeUnary } from 'db/exec/RANode';
import * as React from 'react';
import { t } from 'calc2/i18n';

require('./raTree.scss');
// require('./raTreeFamilyTree.scss');
Expand Down Expand Up @@ -97,6 +98,10 @@ export class RaTree extends React.Component<Props> {
? <pre>{n.getMetaData('inlineRelationDefinition')}</pre>
: null
}
{
n._execTime ? <p>{t('calc.result.exec.time')} {n._execTime}ms</p> : <p>{t('calc.result.exec.time')} fuck - ms</p>
}


</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/calc2/components/result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class Result extends React.Component<Props, State> {

const result = this.result(activeNode);


return (
<div className="ra-result clearfix">
<div>
Expand Down
27 changes: 22 additions & 5 deletions src/calc2/store/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,34 @@ export function loadStaticGroups() {
source: 'gist',
id: 'c306ecf21c6e6d175508d3ac6b4355e7',
},

{
maintainerGroup: t('calc.maintainer-groups.hsd'),
maintainer: '<a href="https://gist.github.com/mafo3186">Mareike Focken</a>',

source: 'gist',
id: 'dd9b9e4a5bd3b9a5265104e4c8f171c6',
},
{
maintainerGroup: t('calc.maintainer-groups.hsd'),
maintainer: '<a href="https://gist.github.com/mafo3186">Mareike Focken</a>',

source: 'gist',
id: '7716a847139f098709a88f1835d5b08b',
},
{
maintainerGroup: t('calc.maintainer-groups.hsd'),
maintainer: '<a href="https://gist.github.com/mafo3186">Mareike Focken</a>',

source: 'gist',
id: 'd37f667154aec34f5c4954723ae01db9',
},
{
maintainerGroup: 'OTH Regensburg',
maintainer: '<a href="https://gist.github.com/jschildgen">Johannes Schildgen</a>',

source: 'gist',
id: 'd67f16874b528abc6e6c88d07a50b2dc',
},




];

let first: boolean = true;
Expand Down
10 changes: 10 additions & 0 deletions src/calc2/views/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ export class Landing extends React.Component {

<h2 id="changelog">Changelog</h2>
<ul>
<li>0.26 - Released 17.07.2022
<ul>
<li>Execution time | #156</li>
</ul>
</li>
<li>0.25 - Released 08.07.2022
<ul>
<li>Increased white space tolerance | #169</li>
</ul>
</li>
<li>0.24 - Released 17.06.2022
<ul>
<li>Fixed problem when replacing multiple operators | #174</li>
Expand Down
1 change: 1 addition & 0 deletions src/db/exec/RANode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export abstract class RANode {
_resultNumRows: number = -1;
_wrappedInParentheses: boolean = false;
_warnings: Warning[] = [];
_execTime: any;

constructor(functionName = '') {
this._functionName = functionName;
Expand Down
27 changes: 14 additions & 13 deletions src/db/parser/grammar_ra.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

/** merges the codeInfo objects of a binary operation
* it is asumed that the right node follows the left one
* it is assumed that the right node follows the left one
*/
function mergeCodeInfo(left, right){
var out = {
Expand Down Expand Up @@ -336,7 +336,7 @@ differenceOperator
{ return o; }

crossJoinOperator
= _ o:(('⨯' / 'x') { return getNodeInfo('crossJoinOperator'); }) __
= _ o:(('⨯' / 'x') { return getNodeInfo('crossJoinOperator'); }) __?
{ return o; }
/ __ o:(('cross'i __ 'join'i) { return getNodeInfo('crossJoinOperator'); }) __
{ return o; }
Expand Down Expand Up @@ -607,7 +607,7 @@ booleanExprWithTrailingWhitspace

// multiple (optional) assignments followed by a expression (using the variables)
root
= _ a2:(assignment __)* a:assignment _
= _ a2:(assignment __?)* a:assignment _ //toDo: checken, ob whitespace zwingend nötig oder nicht
{
var assignments = [a];
for(var i in a2){
Expand All @@ -624,7 +624,7 @@ root
codeInfo: getCodeInfo()
};
}
/ _ a:(assignment __)* e:expression? _
/ _ a:(assignment __?)* e:expression? _ //toDo: checken, ob whitespace zwingend nötig oder nicht
{
var assignments = [];
for(var i = 0; i < a.length; i++){
Expand Down Expand Up @@ -661,7 +661,7 @@ groupRoot
}

tableGroupHeaders
= a:tableGroupHeader b:(__ tableGroupHeader)*
= a:tableGroupHeader b:(__? tableGroupHeader)* //toDo: checken, ob whitespace zwingend nötig oder nicht
{
var headers = [];

Expand Down Expand Up @@ -709,7 +709,7 @@ tableGroupHeader
}

tableGroup
= _ headers:tableGroupHeaders a:(__ assignment)+
= _ headers:tableGroupHeaders a:(__? assignment)+ //toDo: checken, ob whitespace zwingend nötig oder nicht
{
var assignments = [];
for(var i = 0; i < a.length; i++){
Expand Down Expand Up @@ -925,7 +925,7 @@ division


projection
= o:pi a:listOfNamedColumnExpressions __ c:expression_precedence1
= o:pi a:listOfNamedColumnExpressions __? c:expression_precedence1
{
operatorPositions.push(o);
return {
Expand All @@ -937,7 +937,7 @@ projection
}

selection
= o:sigma a:booleanExpr __ c:expression_precedence1
= o:sigma a:booleanExpr __? c:expression_precedence1
{
operatorPositions.push(o);
return {
Expand All @@ -949,7 +949,7 @@ selection
}

renameColumns
= o:rho a:listOfColAssignments __ c:expression_precedence1
= o:rho a:listOfColAssignments __? c:expression_precedence1
{
operatorPositions.push(o);
return {
Expand All @@ -961,7 +961,7 @@ renameColumns
}

renameRelation
= o:rho a:relationName __ c:expression_precedence1
= o:rho a:relationName __? c:expression_precedence1
{
operatorPositions.push(o);
return {
Expand All @@ -972,8 +972,9 @@ renameRelation
};
}

//toDo: __? oder nicht?
groupBy
= o:gamma arg:listOfColumns _ ';' _ arg2:listOfAggFunctionArguments __ c:expression_precedence1
= o:gamma arg:listOfColumns _ ';' _ arg2:listOfAggFunctionArguments __? c:expression_precedence1
{
operatorPositions.push(o);
return {
Expand All @@ -984,7 +985,7 @@ groupBy
codeInfo: getCodeInfo(),
};
}
/ o:gamma (_ ';')? _ arg2:listOfAggFunctionArguments __ child:expression_precedence1
/ o:gamma (_ ';')? _ arg2:listOfAggFunctionArguments __? child:expression_precedence1
{
operatorPositions.push(o);
return {
Expand All @@ -997,7 +998,7 @@ groupBy
}

orderBy
= o:tau a:listOfOrderByArgs __ c:expression_precedence1
= o:tau a:listOfOrderByArgs __? c:expression_precedence1 //toDo: __? oder nicht?
{
operatorPositions.push(o);
return {
Expand Down
1 change: 1 addition & 0 deletions src/db/parser/grammar_sql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare module sqlAst {
| rootSql
| statement
| valueExpr

;

type sqlClause
Expand Down
4 changes: 1 addition & 3 deletions src/db/parser/grammar_sql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ unqualifiedColumnName
error(t('db.messages.parser.error-sql-invalid-column-name', {str: a}));
return a;
}

relation
= a:relationName
{
Expand Down Expand Up @@ -437,8 +437,6 @@ select
codeInfo: getCodeInfo()
};
}


orderBy
= 'order'i __ 'by'i __ arg:listOfOrderByArgs
{
Expand Down
1 change: 1 addition & 0 deletions src/db/relalg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export function queryWithReplacedOperatorsFromAst(
const pegParserSql = require('./parser/grammar_sql.pegjs') as any;

export function parseSQLSelect(text: string): sqlAst.rootSql {

return pegParserSql.parse(
text,
{
Expand Down
Loading

0 comments on commit 709d3c1

Please sign in to comment.