Skip to content

Instantly share code, notes, and snippets.

Avatar

Prateek Asthana prateeka

View GitHub Profile
@prateeka
prateeka / SqlLanguage.scala
Created Sep 21, 2021
ATSCALE-4981 analysis
View SqlLanguage.scala
def makeSelectColumn(gb: GroupByType): Option[SelectColumn] = {
gb match {
case GroupByIgnore => None
case _: GroupByColumnNumber => None
case gbv@GroupByValue(_: ConstantValue, _) if findGroupByTypeColumn(gbv).isEmpty => None
case _ =>
val (exposed, expr) =
gb match {
case GroupByColumnName(name, _, Some(expression)) => (Some(name), expression)
case GroupByValue(_, expression) => (None, expression)
@prateeka
prateeka / SqlLanguage.scala
Last active Sep 18, 2021
atscale-4654: missing group-by clause in outbound query. reason for missing the group-by clause for the ticket are listed here compared to other cases which have group-by clause
View SqlLanguage.scala
def makeSelectColumn(gb: GroupByType): Option[SelectColumn] = {
gb match {
case GroupByIgnore => None
case _: GroupByColumnNumber => None
case gbv@GroupByValue(_: ConstantValue, _) if findGroupByTypeColumn(gbv).isEmpty => None
case _ =>
val (exposed, expr) =
gb match {
case GroupByColumnName(name, _, Some(expression)) => (Some(name), expression)
case GroupByValue(_, expression) => (None, expression)
@prateeka
prateeka / GraphPlanner.scala
Last active Jul 30, 2021
AggLogical-lastchild.lastchild-fail
View GraphPlanner.scala
AggregateLogical(
SelectedData(
ColumnData(SelectColumn(Some(c0),DimensionallyModifiedValue(AggregatedValue(AttributeValue(FlatAttribute(ef1dd654-da9a-42bc-77ef-ea4431bdeb4e: "salesamount1")),Sum),List(Child(Child(CurrentMember(FlatHierarchy(d525ca44-1aa7-4c19-bfa7-ed6e69040b00+1298889108: "Order Date Month Hierarchy")),false),false))),NoAggregation), NoAggregation, Some(c0))
),
AuxiliaryData(),
AggregateLogical(
SelectedData(
DimensionallyModifiedData(ValueData(AggregatedValue(AttributeValue(FlatAttribute(ef1dd654-da9a-42bc-77ef-ea4431bdeb4e: "salesamount1")),Sum),NoAggregation,Set(RawAttribute(FlatAttribute(ef1dd654-da9a-42bc-77ef-ea4431bdeb4e: "salesamount1"),Sum,Some(c_36))),Some(c_37)),List(Child(Child(CurrentMember(FlatHierarchy(d525ca44-1aa7-4c19-bfa7-ed6e69040b00+1298889108: "Order Date Month Hierarchy")),false),false)),Min,Some(c_37))
),
AuxiliaryData(),
@prateeka
prateeka / CalculationResolver.scala
Last active Jul 5, 2021
DistinctCount additionDistinctCount addition
View CalculationResolver.scala
case MdxFunctions.DistinctCount.Applied(valueSet :: HNil) =>
val resolvedVal = ConstantValue(5, IntType)
ComplexAggregatedValue(resolvedVal, resolveSetExpression(valueSet), core.DistinctCountExact)
@prateeka
prateeka / console_1.sql
Last active Dec 6, 2020
'All' level selecting 'min' member instead of 'firstChild' member
View console_1.sql
SELECT
MIN(t_129.c0) AS c0,
MIN(t_129.c_39) AS c1,
t_129.c2 AS c2,
t_129.c3s0 AS c3s0
FROM
(
SELECT
MIN(t_128.c0) AS c0,
MIN(t_128.c_39) AS c_39,
@prateeka
prateeka / console_1.sql
Created Dec 4, 2020
firstChild.name encountering sql group-by error.
View console_1.sql
SELECT
MIN(t_101.c_44) AS c0,
t_101.c1 AS c1,
t_101.c2s0 AS c2s0
FROM
(
SELECT
MIN(t_98.c_44) AS c_44,
COALESCE(t_100.c_45, t_98.c1) AS c1,
COALESCE(t_100.c_55, t_98.c2s0) AS c2s0
@prateeka
prateeka / firstChild_bug.json
Created Nov 27, 2020
virtualCube for firstChild calculating measure at "targetLevel" instead of "firstChild" level
View firstChild_bug.json
OrderCube(
AggregateLogical(
SelectedData(
ColumnData(SelectColumn(Some(c0),AttributeValue(FlatAttribute(62874bbe-7ead-48ac-4496-8c7758b5aaa8: "orderquantity1")),Sum), Sum, Some(c0)),
ColumnData(SelectColumn(Some(c1),DimensionallyModifiedValue(AggregatedValue(AttributeValue(FlatAttribute(62874bbe-7ead-48ac-4496-8c7758b5aaa8: "orderquantity1")),Sum),List(Child(CurrentMember(FlatHierarchy(9bf44374-c106-4ab3-9c6a-d68474e9b25f+3938: "Product Dimension")),true))),NoAggregation), NoAggregation, Some(c1)),
ColumnData(SelectColumn(Some(c2),AttributeValue(FlatAttribute(2ff18d3a-894a-4be1-6d5c-39d97245160a: "Product Line")),AggregateGrouped(true)), AggregateGrouped(true), Some(c2)),
ColumnData(SelectColumn(Some(c3s0),KeyValue(FlatKey(3b0e5176-ca31-4706-a508-092e3c17daa2)),AggregateGrouped(true)), AggregateGrouped(true), Some(c3s0))
),
AuxiliaryData(),
UnionCubes(
@prateeka
prateeka / firstChild_bug.sql
Created Nov 27, 2020
sql for firstChild calculating measure at "targetLevel" instead of "firstChild" level
View firstChild_bug.sql
SELECT
MIN(t_117.c0) AS c0,
MIN(t_117.c_51) AS c1,
t_117.c2 AS c2,
t_117.c3s0 AS c3s0
FROM
(
SELECT
MIN(t_116.c0) AS c0,
MIN(t_116.c_51) AS c_51,
@prateeka
prateeka / siblingMapping.sql
Last active Nov 26, 2020
FirstSibling mapping table query
View siblingMapping.sql
-- firstSibling sub-level
SELECT st.id orig_id, rk.id mapped_id
FROM (select country_id, id, RANK() over (ORDER BY country_id) _rank from states) st
join (SELECT country_id, id, ROW_NUMBER() over (ORDER BY country_id asc , id asc ) rownumb FROM states) rk
on st._rank = rk.rownumb and rk.country_id = st.country_id;
-- lastSibling sub-level
SELECT st.id orig_id, rk.id mapped_id
FROM (select country_id, id, RANK() over (ORDER BY country_id) _rank from states) st
@prateeka
prateeka / data_setup.sql
Last active Nov 26, 2020
data_setup for country, states, orders
View data_setup.sql
drop table country;
drop table states;
drop table sales;
CREATE TABLE
IF NOT EXISTS country
(
country_id INTEGER IDENTITY(1,1) ,
_name VARCHAR(22) NOT NULL,
UNIQUE ( _name)