We present a new fully data-driven algorithm that uses photometric data from the Canada-France Imaging Survey (CFIS; u), Pan-STARRS 1 (PS1; griz), and Gaia (G) to discriminate between dwarf and giant stars and to estimate their distances and metallicities. The algorithm is trained and tested using the Sloan Digital Sky Survey (SDSS)/SEGUE spectroscopic data set and Gaia photometric/astrometric data set. At [Fe/H]<-1.2, the algorithm succeeds in identifying more than 70% of the giants in the training/test set, with a dwarf contamination fraction below 30% (with respect to the SDSS/SEGUE data set). The photometric metallicity estimates have uncertainties better than 0.2dex when compared with the spectroscopic measurements. The distances estimated by the algorithm are valid out to a distance of at least ~80kpc without requiring any prior on the stellar distribution and have fully independent uncertainties that take into account both random and systematic errors. These advances allow us to estimate these stellar parameters for approximately 12 million stars in the photometric data set. This will enable studies involving the chemical mapping of the distant outer disk and the stellar halo, including their kinematics using the Gaia proper motions. This type of algorithm can be applied in the southern hemisphere to the first release of LSST data, thus providing an almost complete view of the external components of our Galaxy out to at least ~80kpc. Critical to the success of these efforts will be ensuring well-defined spectroscopic training sets that sample a broad range of stellar parameters with minimal biases. A catalog containing the training/test set and all relevant parameters within the public footprint of CFIS is available online.