<commit_before>﻿"use strict";

var SqlTools={};

SqlTools.olap={};

SqlTools.olap.cube=function(sql, pivotVar, varsDef){
    return "no implementado aún";
}

module.exports=SqlTools;<commit_msg>Pasando el primer caso de prueba...<commit_after>﻿"use strict";

var SqlTools={};

SqlTools.olap={};

SqlTools.olap.cube=function(sql, pivotVar, varsDef){
    //return "no implementado aún";
	var consulta = 'WITH "cube_olap" AS (\n ' + sql + ')\n SELECT * FROM "cube_olap"\n UNION SELECT ';
	var aggExp = '';
	for (var i=0; i < varsDef.length; i++) {
		if (varsDef[i].name == pivotVar){
			var aggLabel = varsDef[i].aggLabel; 
		}
		if (varsDef[i].place == 'data'){
		    var dataVar = varsDef[i].name;
			aggExp = aggExp + (varsDef[i].aggExp ? varsDef[i].aggExp : ', sum('+dataVar+')'); 
		}
	}
	consulta = consulta + '\'' + aggLabel + '\'' + aggExp;
	consulta = consulta + ' FROM "cube_olap"';
	return consulta;
}

module.exports=SqlTools;
{'fraction_non_alphanumeric': 0.18609625668449198, 'fraction_numerical': 0.0010695187165775401, 'mean_word_length': 4.142857142857143, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7272040', 'n_tokens_mistral': 388, 'n_tokens_neox': 365, 'n_words': 78}