Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("works in basic case (no count) + re-add", () => {
var attributes1 = AttributeInfo.fromJSs([
{ name: '__time', type: 'TIME' },
{ name: 'page', type: 'STRING' },
{ name: 'added', type: 'NUMBER' },
{ name: 'unique_user', special: 'unique' }
]);
var dataCube1 = dataCubeStub.fillAllFromAttributes(attributes1);
expect(dataCube1.toJS()).to.deep.equal({
"name": "wiki",
"title": "Wiki",
"description": "",
"clusterName": "druid",
"source": "wiki",
"refreshRule": {
"rule": "realtime"
},
it("adds new dimensions", () => {
var columns: any = [
{ name: "__time", type: "TIME" },
{ name: "added", makerAction: { action: "sum", expression: { name: "added", op: "ref" } }, type: "NUMBER", unsplitable: true },
{ name: "count", makerAction: { action: "count" }, type: "NUMBER", unsplitable: true },
{ name: "delta_hist", special: "histogram", type: "NUMBER" },
{ name: "page", type: "STRING" },
{ name: "page_unique", special: "unique", type: "STRING" }
];
var dataCube1 = dataCube.addAttributes(AttributeInfo.fromJSs(columns));
expect(dataCube1.toJS().dimensions).to.deep.equal([
{
kind: "time",
name: "__time",
title: "Time",
formula: "$__time"
},
{
kind: "string",
name: "page",
title: "Page",
formula: "$page"
}
]);
it("works with existing dimension", () => {
var attributes1 = AttributeInfo.fromJSs([
{ name: "__time", type: "TIME" },
{ name: "added", type: "NUMBER" },
{ name: "added!!!", type: "NUMBER" },
{ name: "deleted", type: "NUMBER" }
]);
var dataCubeWithDim = DataCube.fromJS({
name: "wiki",
title: "Wiki",
clusterName: "druid",
source: "wiki",
subsetFormula: null,
introspection: "autofill-all",
defaultTimezone: "Etc/UTC",
refreshRule: {
rule: "realtime"
(resp) => {
var attributes = AttributeInfo.fromJSs(resp.attributes);
if (autoFill) {
newDataCube = newDataCube.fillAllFromAttributes(attributes);
} else {
newDataCube = newDataCube.changeAttributes(attributes);
}
this.loadingDelegate.stop();
this.props.onNext(newDataCube);
},
(xhr: XMLHttpRequest) => {
if (!parameters.name) throw new Error("DataCube must have a name");
const introspection = parameters.introspection;
if (introspection && DataCube.INTROSPECTION_VALUES.indexOf(introspection) === -1) {
throw new Error(`invalid introspection value ${introspection}, must be one of ${DataCube.INTROSPECTION_VALUES.join(", ")}`);
}
const refreshRule = parameters.refreshRule ? RefreshRule.fromJS(parameters.refreshRule) : null;
let timeAttributeName = parameters.timeAttribute;
if (cluster && cluster.type === "druid" && !timeAttributeName) {
timeAttributeName = "__time";
}
const timeAttribute = timeAttributeName ? $(timeAttributeName) : null;
const attributeOverrides = AttributeInfo.fromJSs(parameters.attributeOverrides || []);
const attributes = AttributeInfo.fromJSs(parameters.attributes || []);
let derivedAttributes: Record = null;
if (parameters.derivedAttributes) {
derivedAttributes = Expression.expressionLookupFromJS(parameters.derivedAttributes);
}
let dimensions: Dimensions;
let measures: Measures;
try {
dimensions = Dimensions.fromJS(parameters.dimensions || []);
measures = Measures.fromJS(parameters.measures || []);
if (timeAttribute && !dimensions.getDimensionByExpression(timeAttribute)) {
dimensions = dimensions.prepend(new Dimension({
name: timeAttributeName,
kind: "time",
(resp) => {
var attributes = AttributeInfo.fromJSs(resp.attributes);
c_newDataCube = c_newDataCube.fillAllFromAttributes(attributes);
cubesArr.push(c_newDataCube);
var o = { cubesArr, sources, appSettings };
this.makeFinalCall(o);
},
(xhr: XMLHttpRequest) => {
.then((resp) => {
var attributes = AttributeInfo.fromJSs(resp.attributes);
return dataCube.fillAllFromAttributes(attributes);
});
}
(resp) => {
if (!this.mounted) return;
this.loadingDelegate.stop();
this.setState({
attributeSuggestions: dataCube.filterAttributes(AttributeInfo.fromJSs(resp.attributes))
});
},
(xhr: XMLHttpRequest) => {
stringToValue={(str: string) => str ? AttributeInfo.fromJSs(JSON.parse(str)) : undefined}
type="textarea"
const introspection = parameters.introspection;
if (introspection && DataCube.INTROSPECTION_VALUES.indexOf(introspection) === -1) {
throw new Error(`invalid introspection value ${introspection}, must be one of ${DataCube.INTROSPECTION_VALUES.join(", ")}`);
}
const refreshRule = parameters.refreshRule ? RefreshRule.fromJS(parameters.refreshRule) : null;
let timeAttributeName = parameters.timeAttribute;
if (cluster && cluster.type === "druid" && !timeAttributeName) {
timeAttributeName = "__time";
}
const timeAttribute = timeAttributeName ? $(timeAttributeName) : null;
const attributeOverrides = AttributeInfo.fromJSs(parameters.attributeOverrides || []);
const attributes = AttributeInfo.fromJSs(parameters.attributes || []);
let derivedAttributes: Record = null;
if (parameters.derivedAttributes) {
derivedAttributes = Expression.expressionLookupFromJS(parameters.derivedAttributes);
}
let dimensions: Dimensions;
let measures: Measures;
try {
dimensions = Dimensions.fromJS(parameters.dimensions || []);
measures = Measures.fromJS(parameters.measures || []);
if (timeAttribute && !dimensions.getDimensionByExpression(timeAttribute)) {
dimensions = dimensions.prepend(new Dimension({
name: timeAttributeName,
kind: "time",
formula: timeAttribute.toString()