Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var RowFactory = require('eclairjs/sql/RowFactory') needs to be at Global scope #278

Open
billreed63 opened this issue Jun 28, 2016 · 0 comments

Comments

@billreed63
Copy link
Collaborator

for some reason this code does not work

var trainingRDD =  rdd.map(function(t, RowFactory, SqlDate, SqlTimestamp) {
        var parts = t[2].match(/(\d+)/g);
        var date = new Date(parts[0], parts[1]-1, parts[2]);
        var time = new Date(Date.parse(t[2]+" "+t[3]));
        var row = RowFactory.create([
            t[0],
            t[1],
            new SqlDate(date.getTime()),
            new SqlTimestamp(time.getTime()),
            parseFloat(t[4]),
            parseFloat(t[5]),
            t[6]]);
        return row;
    }, [require('eclairjs/sql/RowFactory'),require('eclairjs/sql/SqlDate'),require('eclairjs/sql/SqlTimestamp')]);

But if you add a require at the global level it does

var RowFactory = require('eclairjs/sql/RowFactory')
var trainingRDD =  rdd.map(function(t, RowFactory, SqlDate, SqlTimestamp) {
        var parts = t[2].match(/(\d+)/g);
        var date = new Date(parts[0], parts[1]-1, parts[2]);
        var time = new Date(Date.parse(t[2]+" "+t[3]));
        var row = RowFactory.create([
            t[0],
            t[1],
            new SqlDate(date.getTime()),
            new SqlTimestamp(time.getTime()),
            parseFloat(t[4]),
            parseFloat(t[5]),
            t[6]]);
        return row;
    }, [require('eclairjs/sql/RowFactory'),require('eclairjs/sql/SqlDate'),require('eclairjs/sql/SqlTimestamp')]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant