18 using System.Collections.Generic;
29 namespace Deveel.Data.Sql.Tables {
38 return table.
GetValue(rowIndex, table.IndexOfColumn(columnName));
42 return table.
GetValue(rowIndex, table.ResolveColumnName(columnName));
46 var rows = table.SelectLast(columnOffset).ToList();
47 return rows.Count > 0 ? table.
GetValue(rows[0], columnOffset) : null;
51 return table.GetLastValue(table.IndexOfColumn(columnName));
55 if (columnOffsets.Length > 1)
56 throw new ArgumentException(
"Multi-column gets not supported.");
58 return new[] {table.GetLastValue(columnOffsets[0])};
62 var rows = table.SelectFirst(columnOffset).ToList();
63 return rows.Count > 0 ? table.
GetValue(rows[0], columnOffset) : null;
67 return table.GetFirstValue(table.IndexOfColumn(columnName));
71 if (columnOffsets.Length > 1)
72 throw new ArgumentException(
"Multi-column gets not supported.");
74 return new[] {table.GetFirstValue(columnOffsets[0])};
78 IList<int> rows = table.SelectFirst(columnOffset).ToList();
80 return sz == table.
RowCount && sz > 0 ? table.
GetValue(rows[0], columnOffset) : null;
84 return table.GetSingleValue(table.IndexOfColumn(columnName));
88 if (columnOffsets.Length > 1)
89 throw new ArgumentException(
"Multi-column gets not supported.");
91 return new[] {table.GetSingleValue(columnOffsets[0])};
105 int keySize = keyValue.Length;
109 var columnIndex = table.
GetIndex(columnOffsets[0]);
110 var list = columnIndex.
SelectEqual(keyValue[0]).ToList();
119 for (
int i = sz - 1; i >= 0; --i) {
120 int rIndex = list[i];
122 for (
int c = 1; c < keySize; ++c) {
123 int columnOffset = columnOffsets[c];
124 var columnValue = keyValue[c];
125 if (columnValue.CompareTo(table.
GetValue(rIndex, columnOffset)) != 0) {
140 throw new ArgumentOutOfRangeException(
"columnOffset");
142 var columnType = table.
TableInfo[columnOffset].ColumnType;
155 return ((IQueryTable) table).FindColumn(columnName);
157 if (columnName.
Parent != null &&
171 return table.SelectRowsEqual(table.IndexOfColumn(columnName), value);
179 return table.SelectNotEqual(columnOffset, table.MakeObject(columnOffset, value));
183 var result =
new List<int>();
186 foreach (var rowIndex
in index1) {
187 var tableValue = table.GetValue(rowIndex, columnIndex2);
188 if (tableValue.IsEqualTo(value2))
189 result.Add(rowIndex);
204 return table.SelectRowsGreater(columnOffset, table.MakeObject(columnOffset, value));
212 return table.SelectRowsGreaterOrEqual(columnOffset, table.MakeObject(columnOffset, value));
220 return table.SelecRowsLess(columnOffset, table.MakeObject(columnOffset, value));
228 return table.SelectRowsLessOrEqual(columnOffset, table.MakeObject(columnOffset, value));
236 return table.Select(x => x.RowId.RowNumber);
254 throw new NotSupportedException();
256 var columnName = objRef.ReferenceName;
258 var column = table.FindColumn(columnName);
260 throw new InvalidOperationException();
264 throw new InvalidOperationException();
269 return table.SelectRows(column, binOperator, value);
274 if (columnOffsets.Length > 1)
275 throw new NotSupportedException(
"Multi-column selects not supported yet.");
277 return SelectRows(table, columnOffsets[0], op, values[0]);
282 var colType = table.
TableInfo[column].ColumnType;
286 return new List<int>(0);
294 var colType = table.
TableInfo[column].ColumnType;
297 return new List<int>(0);
308 return index.SelectNotEqual(value);
310 return index.SelectGreater(value);
312 return index.SelectLess(value);
314 return index.SelectGreaterOrEqual(value);
316 return index.SelectLessOrEqual(value);
321 rangeSet = rangeSet.Intersect(op, value);
322 return index.SelectRange(rangeSet.ToArray());
325 public static IEnumerable<int>
Search(
this ITable table,
int column,
string pattern) {
326 return table.Search(column, pattern,
'\\');
329 public static IEnumerable<int>
Search(
this ITable table,
int column,
string pattern,
char escapeChar) {
330 var colType = table.
TableInfo[column].ColumnType;
334 throw new InvalidOperationException(
"Unable to perform a pattern search on a non-String type column.");
338 if (index != null && index.HandlesTextSearch)
341 var colStringType = (StringType)colType;
349 StringBuilder prePattern =
new StringBuilder();
351 bool finished = i >= pattern.Length;
352 bool lastIsEscape =
false;
358 prePattern.Append(c);
359 }
else if (c == escapeChar) {
362 prePattern.Append(c);
365 if (i >= pattern.Length) {
379 IEnumerable<int> searchCase;
381 if (i >= pattern.Length) {
389 if (prePattern.Length == 0 ||
390 colStringType.Locale != null) {
397 searchCase = table.SelectAllRows(column);
398 postPattern = pattern;
408 var lowerBounds = prePattern.ToString();
409 int nextChar = prePattern[i - 1] + 1;
410 prePattern[i - 1] = (char)nextChar;
411 var upperBounds = prePattern.ToString();
413 postPattern = pattern.Substring(i);
420 searchCase = table.SelectRowsBetween(column, cellLower, cellUpper);
435 var enumerator = iList.GetEnumerator(0, iList.Count - 1);
437 while (enumerator.MoveNext()) {
440 bool patternMatches =
false;
441 var cell = table.
GetValue(enumerator.Current, column);
447 expression = expression.Substring(preIndex);
450 if (!patternMatches) {
456 return iList.ToList();
464 return table.AsVirtual(() => table.SelectRowsEqual(columnIndex, value));
469 return table.AsVirtual(() => table.SelectRowsEqual(columnName, value));
473 return table.AsVirtual(() => table.SelectAllRows(columnOffset));
478 var binary = (SqlBinaryExpression)expression;
482 var leftRef = binary.Left.AsReferenceName();
485 return table.SimpleSelect(context, leftRef, binary.ExpressionType, binary.Right);
490 var v = expression.EvaluateToConstant(context, null);
493 if (v.IsNull || v ==
false)
494 return table.EmptySelect();
501 int column = table.FindColumn(columnName);
504 throw new ArgumentException(
String.Format(
"Unable to find the column {0} in the condition.", columnName.
Name));
507 if (op.IsSubQuery()) {
512 throw new ArgumentException();
514 IEnumerable<SqlExpression> list;
522 throw new Exception(
"Error with format or RHS expression.");
533 foreach (var expression
in list) {
534 var rowNum = ttable.
NewRow();
537 ttable.SetValue(rowNum, 0, evalExp.Value);
540 ttable.BuildIndexes();
544 return table.SelectAnyAllNonCorrelated(
new[] { columnName }, op, ttable);
548 if (!exp.IsConstant())
549 throw new ArgumentException(
"The search expression is not constant.");
551 var evalExp = exp.
Evaluate(context, null);
553 throw new InvalidOperationException();
557 IEnumerable<int> rows;
570 rows = table.SelectFromPattern(column, op, value);
575 if (!colInfo.IsIndexable)
576 throw new InvalidOperationException(
String.Format(
"Column {0} os type {1} cannot be searched.", colInfo.ColumnName,
577 colInfo.ColumnType));
579 rows = table.SelectRows(column, op, value);
592 var tableResolver = table.GetVariableResolver();
593 List<int> selectedSet =
new List<int>(rowCount);
595 foreach (var row
in table) {
596 int rowIndex = row.RowId.RowNumber;
598 var rowResolver = tableResolver.ForRow(rowIndex);
601 var exp = expression.
Evaluate(context, rowResolver);
603 throw new NotSupportedException();
609 selectedSet.Add(rowIndex);
622 return new List<int>();
633 var likeSet = (List<int>)table.Search(column, ob.ToString());
636 IList<int> originalSet = table.SelectRows(column,
SqlExpressionType.IsNot, nullCell).ToList();
637 int listSize =
System.Math.Max(4, (originalSet.Count - likeSet.Count) + 4);
638 List<int> resultSet =
new List<int>(listSize);
640 int size = originalSet.Count;
641 for (
int i = 0; i < size; ++i) {
642 int val = originalSet[i];
644 if (likeSet.BinarySearch(val) == 0) {
652 return table.Search(column, ob.ToString());
663 List<int> resultList =
new List<int>();
664 var rowList = table.OrderRowsByColumns(columns).ToList();
666 int rowCount = rowList.Count;
667 int previousRow = -1;
668 for (
int i = 0; i < rowCount; ++i) {
669 int rowIndex = rowList[i];
671 if (previousRow != -1) {
675 for (
int n = 0; n < columns.Length && equal; ++n) {
676 var c1 = table.
GetValue(columns[n], rowIndex);
677 var c2 = table.
GetValue(columns[n], previousRow);
678 equal = (c1.CompareTo(c2) == 0);
682 resultList.
Add(rowIndex);
685 resultList.
Add(rowIndex);
688 previousRow = rowIndex;
696 var mapSize = columnNames.Length;
697 var map =
new int[mapSize];
698 for (
int i = 0; i < mapSize; i++) {
699 map[i] = table.IndexOfColumn(columnNames[i]);
702 return table.DistinctBy(map);
712 if (ranges == null || ranges.Length == 0)
714 return thisTable.EmptySelect();
717 if (ranges.Length == 1 &&
725 int column = thisTable.IndexOfColumn(columnName);
729 "Unable to find the column given to select the range of: " +
734 var rows = thisTable.SelectRowsRange(column, ranges);
737 var result =
new VirtualTable(thisTable, rows.ToArray());
748 var rows = table.SelectRows(columnOffset, op, value);
749 return rows.Count() == table.
RowCount;
754 throw new ArgumentException(
String.Format(
"The right table has {0} columns that is different from the specified column names ({1})",
764 var sz = leftColumns.Length;
765 var leftColMap =
new int[sz];
766 var rightColMap =
new int[sz];
767 for (
int i = 0; i < sz; ++i) {
768 leftColMap[i] = table.FindColumn(leftColumns[i]);
771 if (leftColMap[i] == -1)
772 throw new Exception(
"Invalid reference: " + leftColumns[i]);
774 var leftType = table.
TableInfo[leftColMap[i]].ColumnType;
775 var rightType = rightTable.
TableInfo[i].ColumnType;
776 if (!leftType.IsComparable(rightType)) {
777 throw new ArgumentException(
String.Format(
"The type of the sub-query expression {0}({1}) " +
778 "is not compatible with the sub-query type {2}.",
779 leftColumns[i], leftType, rightType));
783 IEnumerable<int> rows;
785 if (!op.IsSubQuery())
786 throw new ArgumentException(
String.Format(
"The operator {0} is not a sub-query form.", op));
805 var highestCells = rightTable.GetLastValues(rightColMap);
808 rows = table.SelectRows(leftColMap, op, highestCells);
812 var lowestCells = rightTable.GetFirstValues(rightColMap);
815 rows = table.SelectRows(leftColMap, op, lowestCells);
818 var singleCell = rightTable.GetSingleValues(rightColMap);
819 if (singleCell != null) {
821 rows = table.SelectRows(leftColMap, op, singleCell);
825 return table.EmptySelect();
829 rows = table.SelectRowsNotIn(rightTable, leftColMap, rightColMap);
831 throw new ArgumentException(
String.Format(
"Operator of type {0} is not valid in ALL functions.", op.SubQueryPlainType()));
849 var lowestCells = rightTable.GetFirstValues(rightColMap);
852 rows = table.SelectRows(leftColMap, op, lowestCells);
856 var highestCells = rightTable.GetLastValues(rightColMap);
859 rows = table.SelectRows(leftColMap, op, highestCells);
862 rows = table.SelectRowsIn(rightTable, leftColMap, rightColMap);
865 var cells = rightTable.GetSingleValues(rightColMap);
868 rows = table.SelectRows(leftColMap, op, cells);
875 throw new ArgumentException(
String.Format(
"Operator of type {0} is not valid in ANY functions.", op.SubQueryPlainType()));
897 var raw1 = thisTable.GetRawTableInfo();
898 var raw2 = otherTable.GetRawTableInfo();
902 var
union = raw1.Union(raw2);
907 var tableList =
union.GetTables().AsEnumerable();
935 smallColumn = column1;
936 largeColumn = column2;
942 smallColumn = column2;
943 largeColumn = column1;
953 foreach (var row
in smallTable) {
954 var cell = row.GetValue(smallColumn);
956 var selectedSet = largeTable.SelectRows(largeColumn, op, cell).ToList();
960 if (selectedSet.Count > 0) {
966 if (largeTable == table) {
968 int sz = selectedSet.Count;
970 for (
int i = 0; rs && i < sz; ++i) {
971 rs = resultRows.UniqueInsertSort(selectedSet[i]);
975 resultRows.Add(row.RowId.RowNumber);
980 return resultRows.ToList();
992 if (t1Cols.Length > 1)
993 throw new NotSupportedException(
"Multi-column 'in' not supported yet.");
995 return table.SelectRowsIn(other, t1Cols[0], t2Cols[0]);
1013 if (t2RowCount == 0)
1015 return table.SelectAllRows(col1);
1017 if (t2RowCount == 1) {
1019 var en = other.GetEnumerator();
1021 throw new InvalidOperationException(
"Cannot iterate through table rows.");
1023 var cell = other.
GetValue(en.Current.RowId.RowNumber, col2);
1030 List<int> resultRows =
new List<int>();
1032 foreach (var row
in table) {
1033 int rowIndex = row.RowId.RowNumber;
1041 if (!selectedSet.Any())
1042 resultRows.
Add(rowIndex);
1057 if (t1Cols.Length > 1)
1058 throw new NotSupportedException(
"Multi-column 'not in' not supported yet.");
1060 return table.SelectRowsNotIn(other, t1Cols[0], t2Cols[0]);
1064 return table.AsVirtual(() => SelectRowsNotIn(table, otherTable, tableColumns, otherColumns));
1068 return new CompositeTable(table,
new[] { table, other },
function, all);
1090 var tabs =
new [] { table, otherTable};
1091 var rowSets =
new IList<int>[2];
1096 rowSets[0] =
new List<int>(0);
1097 rowSets[1] =
new List<int>(0);
1100 List<int> thisRowSet =
new List<int>();
1101 List<int> tableRowSet =
new List<int>();
1104 var tableSelectedSet = otherTable.Select(x => x.RowId.RowNumber).ToList();
1106 int tableSelectedSetSize = tableSelectedSet.Count;
1109 var e = table.GetEnumerator();
1110 while (e.MoveNext()) {
1111 int rowIndex = e.Current.RowId.RowNumber;
1112 for (
int i = 0; i < tableSelectedSetSize; ++i) {
1113 thisRowSet.Add(rowIndex);
1116 tableRowSet.AddRange(tableSelectedSet);
1120 rowSets[0] = thisRowSet;
1121 rowSets[1] = tableRowSet;
1132 return table.Join(otherTable,
true);
1137 var rightExpression = expression;
1140 var rhsVar = rightExpression.AsReferenceName();
1141 var lhsVar = columnName;
1142 var op = operatorType;
1144 if (rhsVar != null) {
1165 return table.SimpleJoin(context, other, joinExp);
1171 throw new ArgumentException();
1174 int lhsColumn = thisTable.FindColumn(objRef.ReferenceName);
1176 if (lhsColumn == -1)
1177 throw new Exception(
"Unable to find the LHS column specified in the condition: " + objRef.ReferenceName);
1181 var resolver = other.GetVariableResolver();
1186 var thisRowSet =
new List<int>();
1187 var tableRowSet =
new List<int>();
1189 var e = other.GetEnumerator();
1191 while (e.MoveNext()) {
1192 int rowIndex = e.Current.RowId.RowNumber;
1194 var rowResolver = resolver.ForRow(rowIndex);
1197 var selectedSet = thisTable.SelectRows(rowResolver, context, binary);
1199 var selectList = selectedSet.ToList();
1201 var size = selectList.Count;
1203 for (
int i = 0; i < size; i++) {
1204 tableRowSet.Add(rowIndex);
1207 thisRowSet.AddRange(selectList);
1212 var tabs =
new[] {thisTable, other};
1213 var rowSets =
new IList<int>[] {thisRowSet, tableRowSet};
1220 var rowList = rightTable.Select(x => x.RowId.RowNumber).ToList();
1222 int colIndex = rightTable.IndexOfColumn(table.GetResolvedColumnName(0));
1223 rowList = rightTable.ResolveRows(colIndex, rowList, table).ToList();
1226 var thisTableSet = table.Select(x => x.RowId.RowNumber).ToList();
1228 thisTableSet.Sort();
1232 List<int> resultList =
new List<int>(96);
1233 int size = thisTableSet.Count;
1234 int rowListIndex = 0;
1235 int rowListSize = rowList.Count;
1236 for (
int i = 0; i < size; ++i) {
1237 int thisVal = thisTableSet[i];
1238 if (rowListIndex < rowListSize) {
1239 int inVal = rowList[rowListIndex];
1240 if (thisVal < inVal) {
1241 resultList.Add(thisVal);
1242 }
else if (thisVal == inVal) {
1243 while (rowListIndex < rowListSize &&
1244 rowList[rowListIndex] == inVal) {
1248 throw new InvalidOperationException(
"'this_val' > 'in_val'");
1251 resultList.Add(thisVal);
1267 var result = table.SimpleJoin(context, other, onExpression);
1269 int sz = leftColumns.Length;
1277 for (
int i = 1; i < sz; ++i) {
1282 if (restExpression == null) {
1283 restExpression = equalExp;
1289 result = result.ExhaustiveSelect(context, restExpression);
1300 var work = table.OrderBy(columns);
1303 var rowList = work.Select(row => row.RowId.RowNumber);
1305 return work.ResolveRows(0, rowList, table);
1311 ITable resultTable = table;
1312 for (
int i = columns.Length - 1; i >= 0; --i) {
1313 resultTable = resultTable.OrderBy(columns[i],
true);
1318 throw new InvalidOperationException(
"The final row count mismatches.");
1327 var rows = table.SelectAllRows(columnIndex);
1330 if (@ascending ==
false)
1331 rows = rows.Reverse();
1337 var columnOffset = table.IndexOfColumn(columnName);
1338 if (columnOffset == -1)
1339 throw new ArgumentException(
String.Format(
"Column '{0}' was not found in table.", columnName));
1341 return table.OrderBy(columnOffset, @ascending);
1347 int sz = ascending.Length;
1348 for (
int n = sz - 1; n >= 0; --n) {
1349 result = result.OrderBy(columnNames[n], ascending[n]);
1355 return table.OrderBy(table.ResolveColumnName(columnName), ascending);
1361 var columnMap =
new int[columnNames.Length];
1363 for (
int i = 0; i < columnMap.Length; i++) {
1364 columnMap[i] = table.IndexOfColumn(columnNames[i]);
1373 return table.SelectRowsEqual(columnOffset, value).Any();
1377 return table.SelectRowsEqual(columnOffset1, value1, columnOffset2, value2).Any();
1386 throw new InvalidOperationException(
"Tables have different row counts.");
1390 List<int> allRowSet =
new List<int>();
1392 for (
int i = 0; i < rcount; ++i) {
1396 var tabs =
new[] { table, other };
1397 var rowSets =
new IList<int>[] { allRowSet, allRowSet };
1404 throw new NotSupportedException(
"Table must have two columns.");
1406 var map =
new Dictionary<string, ISqlObject>();
1407 foreach (var row
in table) {
1408 var key = row.GetValue(0);
1409 var value = row.GetValue(1);
1410 map[key.AsVarChar().Value.ToString()] = value.Value;
IEnumerable< int > SelectEqual(DataObject ob)
virtual IEnumerable< int > SelectFirst()
Provides a set of extension methods to ITable and IMutableTable objects.
override SqlExpressionType ExpressionType
bool IsNull
Gets a value that indicates if this object is materialized as null.
Defines the contract to access the data contained into a table of a database.
SqlType Type
Gets the SqlType that defines the object properties
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
static IEnumerable< int > SelectRowsGreater(this ITable table, int columnOffset, ISqlObject value)
static DataObject MakeObject(this ITable table, int columnOffset, ISqlObject value)
An expression that references an object within a context.
A long string in the system.
IEnumerable< int > SelectGreaterOrEqual(DataObject ob)
static SqlBinaryExpression And(SqlExpression left, SqlExpression right)
static ITable SimpleSelect(this ITable table, IRequest context, ObjectName columnName, SqlExpressionType op, SqlExpression exp)
static Row GetRow(this ITable table, int rowNumber)
static DataObject GetSingleValue(this ITable table, string columnName)
static ITable NotIn(this ITable table, ITable otherTable, int[] tableColumns, int[] otherColumns)
static bool AllRowsMatchColumnValue(this ITable table, int columnOffset, SqlExpressionType op, DataObject value)
static IEnumerable< int > Search(this ITable table, int column, string pattern, char escapeChar)
static ITable OuterJoin(this ITable table, ITable rightTable)
static ITable Execept(this ITable table, ITable other, bool all)
IEnumerable< int > SelectLast()
static ITable Union(this ITable thisTable, ITable otherTable)
Describes the range of values to select from an index.
static readonly IndexRange FullRange
The entire range of values in an index (including NULL)
int Id
Gets a unique identifier of the table in a database system.
static IEnumerable< int > SelectRowsEqual(this ITable table, string columnName, DataObject value)
virtual bool IsComparable(SqlType type)
Verifies if a given SqlType is comparable to this data-type.
static IEnumerable< int > Search(this ITable table, int column, string pattern)
static IEnumerable< int > SelectFirst(this ITable table, int columnOffset)
static DataObject Null(SqlType type)
static ITable SelectAll(this ITable table, int columnOffset)
static IEnumerable< int > SelecRowsLess(this ITable table, int columnOffset, DataObject value)
static IEnumerable< int > SelectRowsGreaterOrEqual(this ITable table, int columnOffset, ISqlObject value)
static SqlBinaryExpression Equal(SqlExpression left, SqlExpression right)
static IEnumerable< int > SelectFromPattern(this ITable table, int column, SqlExpressionType op, DataObject ob)
static bool Exists(this ITable table, int columnOffset, DataObject value)
Describes the name of an object within a database.
ISqlObject Value
Gets the underlined value that is handled.
A single row in a table of a database.
static DataObject String(string s)
override bool Equals(object obj)
static ITable ExhaustiveSelect(this ITable table, IRequest context, SqlExpression expression)
static DataObject[] GetFirstValues(this ITable table, int[] columnOffsets)
DataObject GetValue(long rowNumber, int columnOffset)
Gets a single cell within the table that is located at the given column offset and row...
SqlExpressionType
All the possible type of SqlExpression supported
static ITable SimpleJoin(this ITable thisTable, IRequest context, ITable other, SqlBinaryExpression binary)
static bool PatternMatch(string pattern, string expression, char escapeChar)
This is the pattern match recurrsive method.
ObjectName TableName
Gets the fully qualified name of the table that is ensured to be unique within the system...
static DataObject GetValue(this ITable table, int rowIndex, ObjectName columnName)
static TemporaryTable SingleColumnTable(IContext database, string columnName, SqlType columnType)
Defines the contract for a valid SQL Object
static ITable OrderBy(this ITable table, ObjectName[] columnNames, bool[] ascending)
virtual SqlExpression Evaluate(EvaluateContext context)
When overridden by a derived class, this method evaluates the expression within the provided context...
static IEnumerable< int > SelectRowsBetween(this ITable table, int column, DataObject minCell, DataObject maxCell)
static IEnumerable< int > SelectRowsNotIn(this ITable table, ITable other, int[] t1Cols, int[] t2Cols)
A multi-column version of NOT IN.
static ITable Join(this ITable table, ITable otherTable, bool quick)
static ITable Intersect(this ITable table, ITable other, bool all)
static ITable SelectAnyAllNonCorrelated(this ITable table, ObjectName[] leftColumns, SqlExpressionType op, ITable rightTable)
static ITable Composite(this ITable table, ITable other, CompositeFunction function, bool all)
static IEnumerable< int > SelectNotEqual(this ITable table, int columnOffset, ISqlObject value)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
static IEnumerable< int > SelectRowsIn(this ITable table, ITable other, int[] t1Cols, int[] t2Cols)
A multi-column version of IN.
IEnumerable< int > SelectRange(IndexRange range)
static IEnumerable< int > SelectRowsEqual(this ITable table, int columnIndex1, DataObject value1, int columnIndex2, DataObject value2)
static ITable Join(this ITable table, IRequest context, ITable other, ObjectName columnName, SqlExpressionType operatorType, SqlExpression expression)
static DataObject GetLastValue(this ITable table, string columnName)
static ITable DistinctBy(this ITable table, ObjectName[] columnNames)
static ITable OrderBy(this ITable table, int[] columns)
static IEnumerable< int > FindKeys(this ITable table, int[] columnOffsets, DataObject[] keyValue)
TableInfo TableInfo
Gets the metadata information of the table, used to resolve the column sources.
static int IndexOfColumn(this ITable table, ObjectName columnName)
int RowCount
Gets the total number of rows in the table.
static DataObject GetLastValue(this ITable table, int columnOffset)
static bool IsWildCard(char ch)
Returns true if the given character is a wild card (unknown).
static Dictionary< string, ISqlObject > ToDictionary(this ITable table)
IEnumerable< int > SelectGreater(DataObject ob)
IEnumerable< int > SelectBetween(DataObject ob1, DataObject ob2)
static ITable SelectEqual(this ITable table, string columnName, DataObject value)
static DataObject[] GetLastValues(this ITable table, int[] columnOffsets)
int IndexOfColumn(string columnName)
Gets the offset of the column with the given name.
static IEnumerable< int > SelectRowsNotIn(this ITable table, ITable other, int col1, int col2)
This implements the not in command.
An interface to resolve a variable name to a constant object.
static IEnumerable< int > SelectRowsLessOrEqual(this ITable table, int columnOffset, DataObject value)
static ITable Select(this ITable table, IRequest context, SqlExpression expression)
Defines the value of a ROWID object, that is a unique reference within a database system to a single ...
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
static IEnumerable< int > SelectRowsGreater(this ITable table, int columnOffset, DataObject value)
static ITable AsVirtual(this ITable table, Func< IEnumerable< int >> selector)
override bool Equals(object obj)
IEnumerable< int > SelectLess(DataObject ob)
An expression that holds a constant value.
static IEnumerable< int > SelectNotEqual(this ITable table, int columnOffset, DataObject value)
static DataObject GetValue(this ITable table, int rowIndex, string columnName)
string Name
Gets the name of the object being referenced.
static ITable OrderBy(this ITable table, int columnIndex, bool ascending)
static ITable Subset(this ITable table, ObjectName[] columnNames, ObjectName[] aliases)
static SqlReferenceExpression Reference(ObjectName objectName)
static ITable SelectEqual(this ITable table, int columnIndex, DataObject value)
static ITable DistinctBy(this ITable table, int[] columns)
static ITable EquiJoin(this ITable table, IRequest context, ITable other, ObjectName[] leftColumns, ObjectName[] rightColumns)
static int IndexOfColumn(this ITable table, string columnName)
static IEnumerable< int > SelectLast(this ITable table, int columnOffset)
int ColumnCount
Gets a count of the columns defined by this object.
static DataObject GetFirstValue(this ITable table, int columnOffset)
static IEnumerable< int > SelectRows(this ITable table, int[] columnOffsets, SqlExpressionType op, DataObject[] values)
IEnumerable< int > SelectNotEqual(DataObject ob)
static IEnumerable< int > SelectRowsRange(this ITable table, int column, IndexRange[] ranges)
static DataObject GetFirstValue(this ITable table, string columnName)
CompositeFunction
The kind of composite function in a CompositeTable.
static SqlBinaryExpression Binary(SqlExpression left, SqlExpressionType expressionType, SqlExpression right)
static IEnumerable< int > SelectRowsGreaterOrEqual(this ITable table, int columnOffset, DataObject value)
Defines the base class for instances that represent SQL expression tree nodes.
An object that provides methods for accessing a finite collection of SQL expressions.
static IEnumerable< int > SelectRows(this ITable table, IVariableResolver resolver, IRequest context, SqlBinaryExpression expression)
IEnumerable< int > SelectLessOrEqual(DataObject ob)
Object used to represent a column in the ORDER BY clauses of a select statement.
static ITable SelectRange(this ITable thisTable, ObjectName columnName, IndexRange[] ranges)
abstract SqlExpressionType ExpressionType
Gets the type code of this SQL expression.
static IEnumerable< int > SelectRowsIn(this ITable table, ITable other, int column1, int column2)
This implements the in command.
static IEnumerable< int > SelecRowsLess(this ITable table, int columnOffset, ISqlObject value)
static DataObject[] GetSingleValues(this ITable table, int[] columnOffsets)
static IEnumerable< int > SelectAllRows(this ITable table, int columnOffset)
IEnumerable< int > SelectLike(DataObject value)
DataObject Add(DataObject other)
Adds the given value to this object value.
virtual IEnumerable< int > SelectAll()
static IEnumerable< int > OrderRowsByColumns(this ITable table, int[] columns)
static ITable NaturalJoin(this ITable table, ITable otherTable)
static ITable ColumnMerge(this ITable table, ITable other)
This is a static class that performs the operations to do a pattern search on a given column of a tab...
Deveel.Data.Sql.Objects.SqlString SqlString
static ITable OrderBy(this ITable table, string columnName, bool ascending)
static bool Exists(this ITable table, int columnOffset1, DataObject value1, int columnOffset2, DataObject value2)
static DataObject GetSingleValue(this ITable table, int columnOffset)
static IEnumerable< int > SelectRows(this ITable table, int column, SqlExpressionType op, DataObject value)
ColumnIndex GetIndex(int columnOffset)
Gets an index for given column that can be used to select values from this table. ...
static IEnumerable< int > SelectRowsLessOrEqual(this ITable table, int columnOffset, ISqlObject value)
static ITable EmptySelect(this ITable table)
static ITable OrderBy(this ITable table, ObjectName columnName, bool ascending)
static IEnumerable< int > SelectRowsEqual(this ITable table, int columnIndex, DataObject value)
static IEnumerable< int > SelectAllRows(this ITable table)