Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
113 lines (95 loc) · 3.51 KB

File metadata and controls

113 lines (95 loc) · 3.51 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace QueryTree.Engine
{
public class SelectNode : DataProcessorNode
{
private IList<int> IncludedColumnIndexes;
private IList<string> ColumnAliases;
public override void UpdateSettings(Dictionary<string, object> settings)
{
IncludedColumnIndexes = new List<int>();
ColumnAliases = new List<string>();
base.UpdateSettings(settings);
if (settings.ContainsKey("IncludedColumnIndexes") && settings["IncludedColumnIndexes"] != null)
{
IncludedColumnIndexes = JsonConvert.DeserializeObject<List<int>>(settings["IncludedColumnIndexes"].ToString());
}
if (settings.ContainsKey("ColumnAliases") && settings["ColumnAliases"] != null)
{
ColumnAliases = JsonConvert.DeserializeObject<List<string>>(settings["ColumnAliases"].ToString());
}
}
public override bool IsConfigured()
{
return Inputs.Count == 1
//&& len(self.columns) > 0
&& IncludedColumnIndexes.Count > 0;
}
public override IList<string> GetColumns()
{
var newCols = new List<string>();
var inputCols = InputDict[Inputs[0]].GetColumns();
foreach (var colIndex in IncludedColumnIndexes)
{
if (colIndex < inputCols.Count)
{
newCols.Add(inputCols[colIndex]);
var i = newCols.Count - 1;
if (ColumnAliases.Count > i && ColumnAliases[i] != null)
{
newCols[i] = ColumnAliases[i];
}
}
}
return newCols;
}
public override IList<string> GetColumnTypes()
{
var newColTypes = new List<string>();
var inputColTypes = InputDict[Inputs[0]].GetColumnTypes();
foreach (var colIndex in IncludedColumnIndexes)
{
if (colIndex < inputColTypes.Count)
{
newColTypes.Add(inputColTypes[colIndex]);
}
}
return newColTypes;
}
public override string GetQuerySql()
{
var input1 = InputDict[Inputs[0]];
var input1Columns = input1.GetColumns();
var sql = "SELECT ";
var colCount = 0;
var separator = "";
foreach (var colIndex in IncludedColumnIndexes)
{
if (colIndex < input1Columns.Count)
{
if (input1 is ICollapsibleQueryNode)
{
sql += string.Format("{0}{1} AS Column_{2:D}", separator, (input1 as ICollapsibleQueryNode).GetRawColumnName(colIndex), colCount);
}
else
{
sql += string.Format("{0}{1} AS Column_{2:D}", separator, input1.GetColumnName(colIndex), colCount);
}
colCount += 1;
separator = ",";
}
}
if (input1 is ICollapsibleQueryNode)
{
sql += (input1 as ICollapsibleQueryNode).GetTableFrom();
}
else
{
sql += string.Format(" FROM {0} ", input1.GetDependencySql());
}
return sql;
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.